This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: CL implementation questions
- From: Charles Turner <chturne at gmail dot com>
- To: Per Bothner <per at bothner dot com>
- Cc: Kawa mailing list <kawa at sourceware dot org>
- Date: Tue, 3 Apr 2012 18:27:12 +0100
- 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> <4F77D526.9000109@bothner.com>
Hi,
On 1 April 2012 05:10, Per Bothner <per@bothner.com> wrote:
> On 03/31/2012 01:25 PM, Charles Turner wrote:
>> - 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.
I'm struggling to set the type of a Declaration (I assume that's all I
need to do), I'm doing the following in Lisp2Compilation
// decls is e.g '((integer x) (gnu.lists.sequence y))
while (decls != LList.Empty) {
pair = (Pair) decls;
x = (LList) pair.getCar();
// In Lambda, this is a PairWithPosition, but making one doesn't
change the
// fact that the types aren't being enforced
Object type = x.get(0);
Object var = x.get(1);
decl = this.lexical.get(var);
decl.setType(new LangExp(type), null);
decl.setFlag(Declaration.TYPE_SPECIFIED);
decls = (LList)pair.getCdr();
}
The #setType and #setFlag methods seem to be all that's need to set
the type of variables with :: (cf Lambda), what am I missing here?
Thanks,
Charlie