CL implementation questions
Charles Turner
chturne@gmail.com
Tue Apr 3 17:27:00 GMT 2012
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
More information about the Kawa
mailing list