[pro] Lisp 2's and function values.

Martin Simmons martin at lispworks.com
Wed May 25 11:45:20 UTC 2011


>>>>> On Wed, 25 May 2011 07:34:22 +0200, Pascal Costanza said:
> 
> On 25 May 2011, at 04:51, Matthew D. Swank wrote:
> 
> > I have implemented a small fexpr interpreter in Common Lisp based on
> > Kernel http://web.cs.wpi.edu/~jshutt/kernel.html. Right now it's a Lisp
> > 1, but I am considering trying to make it a more idiomatic extension of
> > Common Lisp by making it a Lisp 2.
> > 
> > Part of the Lisp 2-ness of the Common Lisp evaluator is that the car of
> > a form must name a function, macro, or special form. This name is either
> > a symbol bound in the function name space, or a lambda expression.
> > However, Kernel just requires the car evaluate to a combiner (this is
> > what Kernel calls a generic operator). Obviously, in a Lisp 2, a symbol
> > would evaluate to the value bound to it in the function name space. 
> > However, consider the following:
> > 
> > ((returns-a-function) arg arg ...)
> > 
> > Would it be reasonable to allow this as a legal form as well?
> > 
> > I'm not arguing Common Lisp should work this way, but I seems to make
> > sense in the context of a Kernel like evaluator.
> 
> _If_ (returns-a-function) indeed returns a function, then this could be
> ok. But what if it doesn't return a function? What if it is a macro that
> returns just a symbol? Do you want to risk that ((return-something) ...) has
> a different meaning than (funcall (return-something) ...)? This is
> potentially confusing and could lead to code that is hard to debug...

Maybe no harder than other Lisp-2's :-)

It seems like an interesting extension of the term "Lisp-2" -- as well as just
specifying different namespaces, the proposal is to have a different evaluator
for the car of the form.  In fact, CL already has one, but it is very limited.

If that evaluator allows macro forms, then a macro that expands to a symbol
should work as if the symbol was used directly.  If you use such a macro with
(funcall (return-something) ...), then you are using the regular evaluator for
the macro form.

-- 
Martin Simmons
LispWorks Ltd
http://www.lispworks.com/




More information about the pro mailing list