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

Re: declare in with-slots

    From:	DECWRL::"kempf@Sun.COM"  "11-Aug-88 0806 PDT" 11-AUG-1988 11:09:28.36

    >Just because the expansion is relatively simple doesn't, of course, mean that
    >it's really the "right" thing to do.

    Are we talking religion or engineering? If the former, then count me in
    as a lang-nostic. :-)

Sometimes it's hard to tell the difference.

    Seriously, there is rarely ever a single "right" way to engineer anything.
    There are usually pros and cons on both sides. The "pro" of this solution
    is that it is simple, the "con" is that it treats type declarations for
    pseudo variables differently from those for lexical variables or other

I tend to believe that in engineering as elsewhere, "separate but
equal" facilities are never really "equal".  Declarations are
ultimately handled by the interpreter/compiler (even if you change a
"declare" into a "the"), and I anticipate lossage if macros try to
intercept them beforehand.  I'm just not confident that declarations
are understood well enough for this to be well-behaved.

    >What if I, a random user, wish to write e.g. my own "with-file-attributes"
    >macro, that lets me access things like the read and write dates for a file as
    >symbol-macrolet "variables".  Not being an implementor, I don't have access to
    >the system declaration-parsing stuff, so I can't support declarations in the
    >way you're proposing for with-slots and with-accessors.  I cry "no fair".

    This is a valid point, but I wonder if it isn't in the same category as
    generalized code walkers.

When I write a generalized code walker, I expect this level of hair,
while with-file-attributes seems like it should be simple to write.

    >I am aware of no other macro which has to parse declarations -- they just get
    >pushed off to some special form or other.  I think that, for what you're
    >trying to do, you have to make symbol-macrolet be a special form, and do
    >declaration processing there.

    Two points here. First, though I've got no objection either way on making
    symbol-macrolet be a special form, the goal of Common Lisp was (and I
    think still is) to limit the number of special forms.  

Well, we could give up, say, GO, and that would make for fewer special
forms :-).  I think that "pseudovariables" represent a real change in
the language semantics, and require a special form.  (As you probably
know, my personal preference would be to remove symbol-macrolet
altogether, rather than introduce a new special form.  But if you keep
the feature, I think you have to pay the price of a special form to
realize it.)

							   Second, I think
    it would be a mistake to confuse general declaration parsing with parsing
    of declarations for pseudovariables. Symbol-macrolet will have to do declaration
    parsing for pseudovariable declarations in any event. 

If symbol-macrolet were a special form, it would be the interpreter/
compiler that parsed out the declarations, just as it does for real
variables.  I think it would be a mistake NOT to unify declarations
for pseudovariables with declarations for real variables.

							  While there are no
    macros which currently do declaration parsing, there are plenty which
    do parsing (like defstruct). 

Defstruct gets to define the syntax it's parsing, which makes it
altogether different.  We're talking about having with-slots "skim"
some declaration text, extract the bits it thinks it's interested in,
and then put back what's left, so the interpreter or compiler can see

    As a point of reference, HP Lisp had a special form called let-pseudo
    whose semantics were identical to symbol-macrolet, and were used for
    a similar purpose, namely to provide lexical scopes in which 
    slot names could be used as pseudovariables for slot access. Type
    declarations included in the class definition were included in 
    the substitution form for the pseudovariable. I don't recall if 
    declarations for pseudovariables were parsed (perhaps someone still
    having access to HP Lisp could check), but I wouldn't be suprised
    if they were.

If let-pseudo is really symbol-macrolet in disguise, then it's not
exactly independent evidence.  Also, if let-pseudo is/was a special
form, then it doesn't really apply to the question of macros that
parse declarations.  You can put all kinds of declarations in a
special form; it won't make me unhappy.