[Ecls-list] examples or documentation on debugging...

Tobias C. Rittweiler tcr at freebits.de
Sat Jun 13 19:16:38 UTC 2009


Juan Jose Garcia-Ripoll writes:

> On Tue, Jun 9, 2009 at 7:50 PM, Tobias C. Rittweiler wrote:
>>> I was also made aware that using form number is not really useful when
>>> the code changes the readtable or use #+ or #-.
>>
>> Examples? People may have to adapt SWANK:*READTABLE-ALIST*, or
>> alternatively use named-readtables at
>>  http://common-lisp.net/~trittweiler/darcs/editor-hints/named-readtables/
>
> I do not know if you notice how quickly requirements pile up: slime,
> additional libraries and coding conventions...

(Actually I was mistakeb that library will not fix that particular
problem but something else.)

The readtable argument is a good one, although tlf numbers _do_ work up
to moderately advanced readtable hacking. They break on custom
reader-macros at the toplevel (because READ + *READ-SUPRESS* can't cope
with that.)

Notice that file positions may not be without their problems, too, due
to different character and/or line encodings.


> I noticed that is what the SBCL port uses. SBCL stores file positions,
> not form numbers. That would make already two implementations relying
> on the same kind of information and maybe on could factor the code
> out.

SBCL uses both, tlf numbers and character offsets.


> > Notice further, that Slime can cope with form paths. A form path is the
> > path into the tree that the source of a toplevel form represents. This
> > way, you can get various highlighting of the actual offending subforms
> > rather than the whole toplevel form.
>
> Unfortunately we do not keep that much information right now. I also
> do not see how it could be kept useful once macros are used -- they
> pretty much change the code structure and slime should then be able to
> decode that. 

The form paths are relative to the original source code. SBCL uses an EQ
hash-table from original sexpr to form-path. During preprocessing, and
later converting the source into its intermediate representation, SBCL
looks up the currently processed form in that table.


> Is it possible? How are source code paths stored? List of indices into
> lists?

Yes, list of INDICES usable for NTH.

Basically:

  (destructuring-bind (tlf-number . form-path) path
    ;; Skip preceding toplevel forms
    (loop repeat tlf-number do (let ((*read-suppress* t)) 
                                 (read STREAM)))
    (let ((tlf (read STREAM)))
      ;; using ELT for swapped arguments
      (reduce #'elt form-path :initial-value tlf)))

  -T.





More information about the ecl-devel mailing list