guile-user
[Top][All Lists]
Advanced

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

Re: Guile top-level functions


From: Neil Jerram
Subject: Re: Guile top-level functions
Date: Mon, 17 Jan 2005 08:38:59 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041007 Debian/1.7.3-5

Kevin Ryde wrote:
Mike Gran <address@hidden> writes:

I had thought it would be neat to color code them by module.  Is there
a way from the C API to find out the filename and line number of a SCM
procedure?


I was wanting that the other day too, from the procedure would be
good, from the module variable would be even better.  The reader gets
the information, but is it thrown away?

Not if you set the 'positions read option, i.e.

(read-enable 'positions)

Then source location information is saved in a weak hash table (scm_source_whash, I think) indexed by each read pair. Given a read expression X, you can get its filename, line and column from

(source-property X 'filename)
(source-property X 'line)
(source-property X 'column)

I'm now sure, though, how to access this for a given procedure; I suspect there are two problems:

- procedure-source may return a new unmemoized copy of the procedure's source, not the original source, and without source properties attached

- it may be impossible to enable the 'positions option early enough in boot-9.scm to catch everything that you want to catch.

I hope this is some help, though.

        Neil




reply via email to

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