This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: CL implementation questions


On 13 April 2012 20:05, Per Bothner <per@bothner.com> wrote:
> On 04/13/2012 11:38 AM, Charles Turner wrote:
>> I should be able to simulate that by creating a new lexical scope for
>> DECLARE:
>>
>> (defun car (x)
>> Â (if (null x) nil (let () (declare (pair x)) (invoke x 'getCar))))
>>
>> This seems quite nasty, it's worse because DECLARE currently doesn't
>> work properly in this case. It sets the type of declaration X to PAIR
>> before runtime IIUC, so this version of CAR rejects inputs like '()
>> because they're not of type PAIR.
>
> Technically this may be allowed by the Common Lisp spec (and even do what
> you need), but let's try the simpler case first with a separate variable:
>
> (defun car (x)
> Â Â(if (null x) nil (let ((xp x)) (declare (pair xp)) (invoke xp 'getCar))))
>
> I suggest implementing CL "the" expression:
>
> (defun car (x)
> Â Â(if (null x) nil (invoke (the pair x) 'getCar)))

I have a similar hang up with THE as I do with DECLARE, how does one
modify the remaining extent of a binding. I suppose it's possible to
rewrite into the case of using a separate variable, but that seems to
be missing your point. I'm also not completely clear on why we need
THE at this time, other than as a nicer way of using a separate
variable.

With (THE value-type form), VALUE-TYPE is not evaluated, but FORM is.
This seems to imply I should be extending Syntax rather than
Procedure, but I'm not sure how to emit code for runtime from a syntax
rewriter, which seems to be necessary in order to modify the extent as
required.

I feel like I missed your suggestion from last time, sorry about this.
(the separate variable does work, though)

Charles.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]