[Ecls-list] how to get the line number of code from error message!

Pascal J. Bourguignon pjb at informatimago.com
Wed May 23 09:41:45 UTC 2012


cm <xiao.ao.jiang.hu.cm at gmail.com> writes:

> I write a hello.lisp file like this:
> (print "hi")
> (length '(a . b 1))
>
> and I load it in to ecl:
>> (load "code/hello.lisp")
>
> ;;; Loading "D:/ECL/code/hello.lisp"
>
> "hi"
> Condition of type: SIMPLE-READER-ERROR
> Reader error in file #<input stream #P"D:/ECL/code/hello.lisp">, position 30:
> Too many objects after a list dot
>
> Available restarts:
>
> 1. (RESTART-TOPLEVEL) Go back to Top-Level REPL.
>
> Broken at SI:BYTECODES. [Evaluation of: (LOAD "code/hello.lisp")] In: #<process
> TOP-LEVEL>.
>
> It has not line number in error message but postion 30.
> I found it is the position of characters.  how to get the line number
> of code from error message?

Like this:

(ql:quickload :com.informatimago.common-lisp.lisp-text)
(use-package :com.informatimago.common-lisp.lisp-text.source-text)

(position 30 (:build-line-index "/tmp/hello.lisp") :test (function <))
--> 2


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.




More information about the ecl-devel mailing list