bharat@uicslsv.cs.uiuc.edu (12/18/88)
I am concerned with the relative efficiencies of using &aux and let for using local variables (I usually use whichever seems to be more aesthetically appropriate), but here are my opinions. There should be little or no difference; however counterintuitively the let block seems to be better in the case where the local is accessed very often. The &aux var. is (probably) affixed to the (end of) the binding list. References to it within another lexical construct (say I am using both a let and &aux) would probably have to assoc through the bindings, while the let variables would be defined in the lexical block. So I conclude that if you are going to use a let at the top level anyway, it is probably more efficient to put all your local vars in the let, rather than &auxing them. Who am I kidding anyway - the short binding lists (with max 10-12 variables - local and otherwise) probably cause no appreciable difference. Any comments? Also what if I did &aux, followed by a setq (not within the variable defn.) - which is better?
caron@polya.Stanford.EDU (Ilan G. Caron) (12/19/88)
In article <4400007@uicslsv> bharat@uicslsv.cs.uiuc.edu writes: > >I am concerned with the relative efficiencies of using &aux and let >for using local variables (I usually use whichever seems to be more >aesthetically appropriate)... > First of all, the semantics of an &AUX is identical to a LET* not a LET. Secondly, I think that your use of aesthetics is entirely the best metric in these circumstances. I suspect that most compilers simply transform the &AUX parameter list into an equivalent LET* (wrapping the function body) so that in compiled code, there is no efficiency issue to speak of. The question is: why does &AUX even exist? is this another throwback to Mac/Inter/Zeta-Lisp? (I'm sure that Scheme wouldn't be caught dead with the extra verbiage). --ilan
barmar@think.COM (Barry Margolin) (12/20/88)
In article <5727@polya.Stanford.EDU> caron@polya.Stanford.EDU (Ilan G. Caron) writes: >The question is: why does &AUX even exist? &AUX was presumably invented because Lisp programmers often found that the first thing they did in a function was to bind a bunch of local variables. Putting these variable bindings into the lambda-list saves an indentation level. I sometimes use &AUX when I am modifying a function. If I need to invent a new variable for communication between one section and another, I will often put it into the &AUX list rather than wrapping a random portion of the function in a new LET, and then use a SETQ. I realize that it isn't really good style, but if the function is complex it is often the safest way to modify it, rather than trying to reorganize it more cleanly. Barry Margolin Thinking Machines Corp. barmar@think.com {uunet,harvard}!think!barmar
miller@ACORN.CS.ROCHESTER.EDU (12/20/88)
From: Brad Miller <miller@CS.ROCHESTER.EDU> Date: 19 Dec 88 01:40:04 GMT From: caron@polya.Stanford.EDU (Ilan G. Caron) The question is: why does &AUX even exist? is this another throwback to Mac/Inter/Zeta-Lisp? (I'm sure that Scheme wouldn't be caught dead with the extra verbiage). As far as I can tell, the only place you may need them is with BOA-constructors. Anyone else? ---- Brad Miller U. Rochester Comp Sci Dept. miller@cs.rochester.edu {...allegra!rochester!miller}
dlw@odi.UUCP (Dan Weinreb) (12/22/88)
>The question is: why does &AUX even exist? is this another throwback >to Mac/Inter/Zeta-Lisp? &AUX actually predates LET. &AUX, along with &OPTIONAL and &REST, was introduced into the MIT Lisp Machine dialect (later known as Zetalisp) sometime prior to the summer of 1976 (by Richard Greenblatt). All of these &-keywords were borrowed from MDL (a.k.a Muddle), a very unusual dialect of Lisp used by a small group at MIT's Project MAC, in which they were written with double-quotes instead of the ampersand, e.g. "OPTIONAL", "AUX". They were backmigrated into Maclisp some years later. They were never in Interlisp or Scheme. At that time (1976), LET had not been codified as part of the language; many people at MIT had their own LET-like macros, all slightly different and incompatible. Soon thereafter, someone (probably Dave Moon) picked the current LET syntax and installed it as part of the basic Lisp system, implemented (originally) as a macro that expanded into a lambda-combination. This was one of the first times a macro had been installed as part of the Lisp system itself. In my own opinion, &AUX is essentially superseded by LET. I gave up using &AUX long ago, and personally don't care for it stylistically. I don't remember why it was carried into Common Lisp; I don't think it should have been. As for the implementation, it could be different in every Lisp, but for the Symbolics 3600 (and Ivory) compiler now in use, I am pretty sure that when I wrote that compiler, I did exactly as you say: transformed it into a LET*. In any case, I would be very surprised if there were any performance difference on the Symbolics 3600 family between &AUX and a top-level LET*. (I haven't actually tested this.) Dan Weinreb, Object Design Inc. (formerly of Symbolics, Inc.)
jbn@glacier.STANFORD.EDU (John B. Nagle) (12/23/88)
"After all parameter specifiers have been processed, the axuiliary variable specifiers (those following the keyword &aux) are processed from left to right. ... Nothing can be done with &aux variables that cannot be done with the special form let*. ... Which to use is purely a matter of style." CLTL, 5.2.2.
andy@solitary.Stanford.EDU (Andy Freeman) (01/03/89)
In article <5727@polya.Stanford.EDU> caron@polya.Stanford.EDU (Ilan G. Caron) writes: >The question is: why does &AUX even exist? &AUX is convenient if you'd like to write a destructuring function defining macro and don't want to figure out how to parse declarations. -andy UUCP: {arpa gateways, decwrl, uunet, rutgers}!polya.stanford.edu!andy ARPA: andy@polya.stanford.edu (415) 329-1718/723-3088 home/cubicle