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

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

Re: [Kawa-commonlisp-dev] [GSoC] Destructuring bind


From: Charles Turner
Subject: Re: [Kawa-commonlisp-dev] [GSoC] Destructuring bind
Date: Fri, 3 Aug 2012 21:44:29 +0100

DESTRUCTURING-BIND is now working for the small amount of testing I've
done so far. Most of the naughty bugs due to unfinished bits of the CL
implementation (symbols, multiple values, differing defaults for
special forms, etc) have been ironed out. Though there still exist
some shockers:

My handling of symbols from the EmptyNamespace needs to be seriously
rethought, as Per has already noticed, keeping the case of these names
is dragon territory. Names like "x" are leaking from the
EmptyNamespace into the current package, so this will fail:

(destructuring-bind (&key x) (list :x 1) (list x))

The first "x" above is leaked from the EmptyNamespace, as is the last
"x". However, ":x" goes through the Keyword#make method and so ends up
as a bona fide Lisp symbol, thus the two are not EQ.

It seems like I need a more conservative lookup strategy. One that
only picks up the standard Scheme names, and not remnants of days past
like "x".

Anyway, here are some results:

#|kawa:1|# (destructuring-bind (x y z) (list 1 2 3) (list x y z))
(1 2 3)
#|kawa:2|# (destructuring-bind (x y z) (list 1 (list 2 20) 3) (list x y z))
(1 (2 20) 3)
#|kawa:3|# (destructuring-bind (a (b c) d) (list 1 (list 2 20) 3)
(list a b c d))
(1 2 20 3)
#|kawa:4|# (destructuring-bind (a (b &optional c) d) (list 1 (list 2
20) 3) (list a b c d))
(1 2 20 3)
#|kawa:5|# (destructuring-bind (a (b &optional c) d) (list 1 (list 2)
3) (list a b c d))
(1 2 () 3)
#|kawa:6|# (destructuring-bind (a (b &optional (c 2)) d) (list 1 (list
2) 3) (list a b c d))
(1 2 2 3)
#|kawa:7|# (destructuring-bind (&key a b c) (list :a 1 :b 2 :c 3) (list a b c))
(1 2 3)
#|kawa:8|# (destructuring-bind (&key a b c) (list :c 3 :b 2 :a 1) (list a b c))
(1 2 3)
#|kawa:9|# (destructuring-bind (&whole w &key a b c) (list :c 1 :b 2
:a 3) (list a b c w))
(3 2 1 (:C 1 :B 2 :A 3))

The work is in my repository, gnu/commonlisp/lisp/defmacro.lisp
(DESTRUCTURING-BIND is temporarily in that file just because it's
trivial with PARSE-DEFMACRO).

I don't fully understand how the files are loaded into Kawa, and the
order in which I should do it. So the build procedure from my
repository (from scratch) is:

Comment out the following line in CommonLisp
loadClass("gnu.commonlisp.lisp.defmacro");

run make
uncomment the previous line
touch gnu/commonlisp/lisp/defmacro.lisp
run make again

!

My plan now is to continue testing this and to actually get some tests
written and installed in the testsuite, which I've been a little
conservative with thus far. After that, there's a lot of other things
I could do, which include:

  * DEFMACRO does not currently use the PARSE-DEFMACRO stuff I've
imported. This would require creating some hooks in the Java code to
process the output of PARSE-DEFMACRO I think.

  * Lots of details to be looked at to with the reader, symbols and
various printing bits.

  * Documentation strings

  * Expanding the test suites!

Charles.



reply via email to

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