From: Ron Garret on
In article <20091031034242.238(a)gmail.com>,
Kaz Kylheku <kkylheku(a)gmail.com> wrote:

> On 2009-10-17, Tim Bradshaw <tfb(a)cley.com> wrote:
> > On 2009-10-17 16:59:16 +0100, Ron Garret <rNOSPAMon(a)flownet.com> said:
> >
> >> I'm not sure, because this is not an example of capture.
> >
> > Yes, it's not. I think I was thinking of some alternative dialect of
> > Lisp where it would be though clearly not being coherent (I *think*
> > that I remember things in Cambridge Lisp, which was the first Lisp I
> > used, where things like this gave problems.
> >
> > I like your terminology though: i was thinking of upward & downward
> > (based on the funarg terminology) but that's not right because that was
> > based on stacks, and this is based on position in source.
>
> I don't think I will be able to remember which is which. These terms
> are inherently ambiguous, because every in has is its out!
>
> Does in refer the referencing direction or the binding direction?

Neither. It refers to the lexical scope of the expansion. Inward
capture involves only symbols that occur inside the lexical scope of the
expansion. Outward capture involves symbols that occur outside the
lexical scope of the expansion.

> The difference is whether the invisible code introduces /references/
> which interfere, or whether it introduces /definitions/ that interfere.

That's not a bad way to think about it. It makes a good exercise to
figure out which type is inward and which is outward.

> If invisible naive references are inserted, this may lead to what
> you are calling inward capture.
>
> If invisible naive definitions are inserted, this may lead to
> outward capture.

Actually, it's (usually) the other way around. :-) But you can actually
invent perverse instances of all four possible combinations.

IMHO there is one (and only one) essential asymmetry in the two types of
capture, and that is that one can be fixed using GENSYM and the other
can't. It's easy to remember which is which if you simply remember that
a macro normally cannot make changes to code outside its lexical scope.

rg
From: Ron Garret on
In article
<5de781e9-6edf-44bc-a179-cdc105e0ef06(a)k33g2000yqa.googlegroups.com>,
vippstar <vippstar(a)gmail.com> wrote:

> On Oct 18, 7:02 pm, Tim Bradshaw <t...(a)cley.com> wrote:
> > On 2009-10-18 13:40:38 +0100, Pascal Costanza <p...(a)p-cos.net> said:
> >
> > > Paul Graham uses the terms "macro argument capture" for what Ron
> > > describes as "inward capture", and "free symbol capture" for "outward
> > > capture" in his book "On Lisp".
> >
> > I much prefer Ron's terminology, as it resonates so well with downward
> > / upward funargs.
>
> I'd rather cite a book instead of a usenet post for my terminology
> though.

I'm actually working on a book :-) Target completion date is early next
year. In the meantime I'll try to make time to write up a blog entry
with a permalink.

rg
From: Ron Garret on
In article <m3k4ysgqe3.fsf(a)moon.robolove.meer.net>,
Madhu <enometh(a)meer.net> wrote:

> * Tim Bradshaw <2009101816511275249-tfb(a)cleycom> :
> Wrote on Sun, 18 Oct 2009 16:51:12 +0100:
>
>
> | Yes, that''s why I didn't want to say "macro" - DEFSTRUCT obviously is
> | a macro, but it clearly is not relevant that it is, as it could
> | obviously (and I'm guessing everyone but Madhu thinks that it
> | obviously *should*) resolve any free references in the environment the
> | macro is defined.
>
> No, I think it should resolve the free references in the environment in
> which the form appears.

Good grief, you haven't learned a thing from this discussion, have you.
"The environment in which the form appears" is AMBIGUOUS because the
spec DOES NOT SPECIFY whether an initform in :included defstruct is to
be treated as if it were a macro expansion or as if it were a lexical
closure. You even agreed to this an another branch of this thread!

So I say one last time: in the case of an :included defstruct, there are
TWO POSSIBLE INTERPRETATIONS of the phrase "the [lexical] environment in
which the [init]form appears." One is the lexical environment of the
DEFSTRUCT that defines the included structure, and the other is the
lexical environment of the including structure. The spec does not
specify which to use, but everyone (except you) agrees that it should be
the former.

Why is this so difficult for you to wrap your brain around?

rg