guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Source locations


From: Joris van der Hoeven
Subject: Re: Source locations
Date: Sun, 9 Feb 2003 20:05:24 +0100 (MET)

Hi,

> > In the online guile manual, I found that the instruction
> > 
> >     (read-enable 'positions)
> > 
> > should tell guile to remember positions in the source code.
> > 
> > How can I use this information? I would like to be able
> > to display a filename and a line/column number when
> > an error is encountered in an embedded guile program.
> 
> If you (read ...) some object `obj' from a file, you can do
> (source-property obj 'filename), (source-property obj 'line) and
> (source-property obj 'column) to get the position where this object
> has been read from.
> 
> Hope this helps.

Thanks for your answer.

Unfortunately, I still do not really understand how to make use of
this in order to display a filename and a line/column number when  
an error is encountered in an embedded guile program.
First of all, I am not sure whether I may use 'load' instead of 'read'.
Secondly, it seems that all this only gives me information about
the object which is read, but not about object which are obtained
indirectly through evaluation. For instance:

address@hidden progs]$ guile
guile> (read-enable 'positions)
(keywords #f positions)
guile> (read-enable 'copy)     
(keywords #f positions copy)
guile> (define f (open-input-file "keywords/split.scm"))
guile> (define prg (read f))
guile> prg
(define process-list (quote ()))
guile> (eval prg)
guile> (source-property process-list 'filename)
standard input:8:1: In procedure source-property in expression
(source-property process-list (quote filename)):
standard input:8:1: Wrong type argument in position 1: ()
ABORT: (wrong-type-arg)

Type "(backtrace)" to get more information.
guile> (source-property prg 'filename)
"keywords/split.scm"
guile> 

Thanks for your attention, Joris


-----------------------------------------------------------
Joris van der Hoeven <address@hidden>
http://www.texmacs.org: GNU TeXmacs scientific text editor
http://www.math.u-psud.fr/~vdhoeven: personal homepage
-----------------------------------------------------------






reply via email to

[Prev in Thread] Current Thread [Next in Thread]