guile-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] Add inspection command "source (, src)" which shows Scheme c


From: Mark H Weaver
Subject: Re: [PATCH] Add inspection command "source (, src)" which shows Scheme code of loaded module
Date: Sun, 31 Mar 2013 23:54:07 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Daniel Hartwig <address@hidden> writes:

> On 31 March 2013 20:47, Nala Ginrut <address@hidden> wrote:
>> On Sat, 2013-03-30 at 17:17 -0400, Mark H Weaver wrote:
>>> Also, as we discussed on IRC, it would be better to show the original
>>> characters in the file instead of the sexp representation.  I want to
>>> see the comments.  I want to see the programmer-chosen indentation.  If
>>> they chose to use curly-infix for some expressions, I want to see that.
>>> More generally, I want to see the presentation that the programmer
>>> thought was most readable, i.e. the *source* code.
>>>
>>
>> For these purposes above, I think there should be a modified 'read' to
>> read the code from source file with comments.
>>
>
> There are other transformations that occur as Mark points out.  It is
> far better to just return the unmodified source from the file.  As
> discussed, the source file, column, line information gives you the
> start, and ‘read’ can be used to locate the end:
>
>  (let ((start (begin
>                 (skip-lines fp (source:line src))
>                 (seek fp (source:column src) SEEK_CUR)
>                 (ftell fp)))
>        (end (begin
>               (read fp)
>               (ftell fp))))
>
>
> these two points are enough information to obtain the unmodified
> source from the file.

This is enough to get the original characters, but then there's the
other problem I mentioned: reader directives such as #!curly-infix
earlier in the file.

For this reason, I think we need to use 'read' from the beginning of the
file, and look at the source properties of the returned datums to find
the right top-level datum.  In most cases, a top-level datum is what is
desired, but in some cases not.  In general, you will need to traverse
the sublists of a top-level datum to find the right one.

     Good luck!
        Mark



reply via email to

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