[Top][All Lists]

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

Re: scratch/accurate-warning-pos: Solid progress: the branch now bootstr

From: Gemini Lasswell
Subject: Re: scratch/accurate-warning-pos: Solid progress: the branch now bootstraps.
Date: Sun, 02 Dec 2018 10:39:31 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1.90 (gnu/linux)

Paul Eggert <address@hidden> writes:

> Yuri Khan wrote:
>> A macro that has a 'position-aware property on
>> it can be called directly on the position-annotated AST and expected
>> to use ‘eq-with-position-information’; while a legacy macro will be
>> called on a de-annotated AST, may use plain ‘eq’, and will return a
>> similarly position-oblivious AST.
> Thanks, this is a good suggestion, perhaps the best idea I've heard so
> far in this thread. Here are a few more suggestions on top of it.

We don't need to invent a new property or rewrite every macro to make
macros work on position-annotated ASTs, because we already have this
feature.  It's (declare (debug ...)), aka Edebug specifications, and it
is how Edebug gets exact source positions when stepping through code
which contains macros.

Paul, you said earlier in this thread that you weren't familiar with
Edebug, so I will attempt to explain how its position annotation works.

In an Edebug specification, a macro author can specify which of the
arguments to a macro (and which structures inside those arguments) are
forms which will be evaluated, and therefore should be
position-annotated, and which are not.  For example in the form

  (dolist (VAR FORM) BODY)

FORM and BODY will be evaluated, but VAR will not be, instead it is
expected to be a symbol which will be bound in the code generated by
'dolist'.  So the Edebug spec for 'dolist' instructs Edebug to annotate
FORM and BODY and leave VAR alone.

If the macro author doesn't provide an Edebug spec, then Edebug doesn't
add position annotations to any of its arguments, and then when
debugging, Edebug will skip over those arguments to the next point of
execution which has a position annotation.

When an Edebug spec instructs it to, Edebug wraps macro arguments with
position annotations, which look just like normal function calls
(because they are) and can be treated by the macro just like any other
Lisp form destined for evaluation.  Edebug's annotated forms look like:

  (edebug-after (edebug-before POS1) POS2 FORM)

where POS1 and POS2 are source code positions for the beginning and end
of FORM (to be precise, they are indices into a vector of source
positions built by the Edebug reader).  FORM could be recursively
annotated if it contains other forms.

For those of you who may have missed it earlier, here are Stefan's
thoughts on how Edebug specs could be used by the byte compiler:

reply via email to

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