Re: Stepper (and debugger)-friendly macros. Case of debugger
Hi All,
I wasn't really responding to the use of, or not, the stepper friendly macros. Rather, I was stating that the stepper is occasionally useful and I would not want to see it discarded.
I need to look more closely at your suggestions, but my initial impression is that they affect only a handful of possibly bothersome instances. There are many macros in the system, and more created all the time. Not sure what your desires are?
If it is based on an inability to discern macros from functions then that is the price one pays for such a flexible system. Any attempt to tighten up the macro facility, like they try to do with hygienic macros in Scheme or Dylan, is counterproductive from my perspective. But given the flexibility of Lisp, you are quite free to implement any variations that you like, and it won't destroy the language flexibility for the rest of us.
- DM
On Mar 3, 2013, at 10:49 AM, Denis Budyak <budden73@gmail.com> wrote:
>
> Hi Thomas!
>
>> I get much better results working back through the stack...
>
> The same problem occurs, the same remedy applies. If macroexpander
> copies the code, source-to-binary position correspondence is lost. Let
> me reformulate my example:
>
> (declaim (optimize (debug 3) (speed 0)))
>
> (eval-when (:compile-toplevel :load-toplevel :execute)
> (defmacro breakpointable (&body x) `(progn ,@x))
> (defmacro non-breakpointable (&body x) `(progn ,@(copy-tree x)))
> )
>
> (defun f1 ()
> (breakpointable
> ( ; one can set breakpoint here
> break )))
>
> (defun f2 ()
> (non-breakpointable
> ( ; can't set breakpoint here as source was
> break )))
>
>
> (defmacro assign-source (literal expanded)
> "Says that, for stepper, expanded code is associated with
> literal source"
> `(setf (car ,literal) (car ,expanded)
> (cdr ,literal) (cdr ,expanded)
> ,expanded ,literal))
>
> (eval-when (:compile-toplevel :load-toplevel :execute)
> (defmacro breakpointable-again (&body x)
> (let ((result `(progn ,@(copy-tree x))))
> (assign-source (first x) (first (cdr result)))
> result))
> )
>
> (defun f3 ()
> (breakpointable-again
> ( ; can set a breakpoint
> break)))
> ;;; EOF
>
> Put the code into a buffer and compile it. Then run f1, f2, f3 from a listener.
> For each function, use "find source" button from debugger when break occurs.
>
> You will see:
> In f1 debugger can find (break) position precisely.
> It fails to do so in (f2) and shows enclosing
> (non-breakpointable). In case of complex macros (e.g. "iterate") this is
> nasty as it can be really hard to locate the problem.
> In f3, due to call of "assign source" from macroexpander function,
> debugger can find (break) again.
>
> _______________________________________________
> Lisp Hug - the mailing list for LispWorks users
> lisp-hug@lispworks.com
> http://www.lispworks.com/support/lisp-hug.html
>
>
Dr. David McClain
CTO & Co-Founder
Acudora (TM)
e-mail: david@acudora.com
Tel: (+1) 520-529-2437
_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html