[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: &rest replacement/addition
- To: Barry Margolin <email@example.com>
- Subject: Re: &rest replacement/addition
- From: firstname.lastname@example.org
- Date: Mon, 04 Apr 1988 14:00:00 -0000
- Cc: Sean.Engelson@spice.cs.cmu.edu, email@example.com, firstname.lastname@example.org
- In-reply-to: Barry Margolin <barmar@Think.COM>'s message of Mon, 4 Apr 88 11:09 EDT
Date: Mon, 4 Apr 88 11:09 EDT
From: Barry Margolin <barmar@Think.COM>
Subject: &rest replacement/addition
Cc: email@example.com, firstname.lastname@example.org
Date: Mon, 04 Apr 88 10:24:30 EDT
(defun fu (a &more-args)
(moby-calculation a arg)
This is similar in spirit to MacLisp's lexprs, which also had special
forms for accessing the arguments. However, it needs a minor fix to
prevent it from sharing one of their faults, too. &MORE-ARGS should be
followed by a symbol, which would be used as an argument to the special
Or like the Interlisp nospread, in which
(LAMBDA N (COND ((> N 3) (F (ARG N 1) ...)...)
has the same result as Common Lisp
(LAMBDA (&REST N) (COND((> (LENGTH N)3) (F (NTH N 1) ...)....)
The lambda variable is bound to the count, the actual arguments
usually hide in the stack, but that is of course an implementation
decision. (ARG var pos) fetches the specified positional argument for
the named nospread variable. The compiler often produces better code
when the named variable is the local argument (in Interlisp-D (ARG N
1) emits identical code for a local nospread argument as for the first
argument of a regular lambda arglist).
There is even a (SETARG var pos) for modifying one of the arguments.
It of course has most of the same implementation problems that started
the &REST and APPLY discussion if you decide to implement it via
lists. However, since there is no name for all arguments, you don't
give APPLY the same oportunity to copy or not copy the list which
might be coming in.
Darrel J. Van Buer
p.s. Most interlisp functions which use nospread arguments are of two kinds:
Ones like append which might otherwise be coded as commonlisp &REST
where compiler macros would normally get rid of the arglist consing anyway.
Ones implementing a Commonlisp &OPTIONAL argument.