This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: CL implementation questions
- From: Per Bothner <per at bothner dot com>
- To: Charles Turner <chturne at gmail dot com>
- Cc: Kawa mailing list <kawa at sourceware dot org>
- Date: Sat, 31 Mar 2012 21:10:14 -0700
- Subject: Re: CL implementation questions
- References: <CAPMhJv3gH18NH61qUvMZcZUbUJjB_08x7WC-to4DuDcqZmjkhg@mail.gmail.com> <4F72B408.5020700@bothner.com> <CAPMhJv0FmBAdPQ_o2rM_koU2391CAmD_0BC22A4dZ=u_aWxoew@mail.gmail.com>
On 03/31/2012 01:25 PM, Charles Turner wrote:
Thanks Jamison& Per for the comments.
On 28 March 2012 07:47, Per Bothner<per@bothner.com> wrote:
There may be other problems implementing Common Lisp primitives using
Common Lisp, but declare a good thing to tackle first.
Some questions whilst thinking about how to start:
- Environments, to which parts of a variables extent the DECLARE form affects.
Depends on what you mean by "Environment". If you mean
gnu.mapping.Environment,
then that is wrong. Note declare is a compile-time thing. I figure we
should
treat them similar to Scheme type specifiers, which attach to Declaration
objects. Of course type specifiers have runtime effects (such as
casts), but the primary goal should be to be able to express using
Common Lisp syntax what is already supported for Scheme. Presumably
there may be some incompatibilities between how Scheme type specifies
work and how declare works, but we can fine-tune the semantics later.
- Its special semantics, i.e. it appears computationally invisible,
only making a difference in certain forms.
I would modify the reader to check for declarations at the start of
each body.
Modifying the reader seems wrong. What you need to modify is the
"rewriter". For example, for lambda you need to modify or override
kawa.lang.Lambda.rewriteBody. That calls Translator.rewrite_body,
which seems like a good place to hook in declaration-processing.
My first suggestion would be to override rewrite_body method in
Lisp2Compilation such that it just processes the declare forms,
and then calls super.rewrite_body. This might not work, if it
doesn't you'll know better why not.
- Macro forms cannot expand into DECLARE exprs.
Why not?
- Code generation
I suppose there's existing examples of similar generation. I imagine
it would just about to emitting the byte code equivalent of if (var
instanceof type) .. when assigning values to variables and such like.
To start with, just use the existing code generation support as used
to implement Scheme type specifiers and coercions.
--
--Per Bothner
per@bothner.com http://per.bothner.com/