kawa-commonlisp-dev
[Top][All Lists]
Advanced

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

Re: [Kawa-commonlisp-dev] Appropiate expression class


From: Per Bothner
Subject: Re: [Kawa-commonlisp-dev] Appropiate expression class
Date: Sun, 03 Mar 2013 11:26:21 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130219 Thunderbird/17.0.3

On 03/03/2013 11:08 AM, Charles Turner wrote:
Hi all,

For the default values in ordinarly lambda lists, I can't see which
Expression class should properly hold them.

The general class is Expression.  Commonly it's a QuoteExp, but not always,
but the default value is an arbitrary expression.

(I think you've been away from Kawa too long, since I believe
you know this if you think about it ...)

Kawa handles this for Scheme.  The only extra complication for
Common Lisp is the supplied_p variable.

One way to handle supplied_p without changing gnu.expr is with a
dummy variable:

(lambda (&optional (x x_default x-p)) body)

becomes:

(lambda (&optional ($incoming$x #!undefined))
   (let ((x_p (eq $incoming$x #!undefined))
         (x (if x_p $incoming$x x_default)))
     body)

My first thought was a
QuoteExp, so to generate the abstract syntax for checking a whether an
argument was passed, I had something like:

new IfExp(new ReferenceExp(supplied_p variable),
             new ReferenceExp(variable passed in),
             new QuoteExp(default value));
                    ^^^^^^^^^

The QuoteExp here isn't right, because with I get results like this:

#|kawa:2|# ((lambda (&optional (x 'a x-p) (y 'b y-p) (z 'c z-p)) (list
x y z x-p y-p z-p)))
((quote a) (quote b) (quote c) () () ())

Here, because the default is of the form (quote x), I'm creating
(quote (quote x)). I'm not sure which Expression class best represents
this "any valid lisp form".

The Translator#rewrite methods take care of this.
--
        --Per Bothner
address@hidden   http://per.bothner.com/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]