[Top][All Lists]

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

Re: %nil once again

From: Andy Wingo
Subject: Re: %nil once again
Date: Thu, 23 Jul 2009 22:35:20 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (gnu/linux)

Hi Daniel!

Reviewing (and merging as much as possible of) your elisp branch is my
next Guile task, after taking care of that bug recently reported by
Martin Ward. Should be short work at this point.

This is a little late, but fwiw...

On Thu 16 Jul 2009 15:47, Daniel Kraft <address@hidden> writes:

> I think I got the test-suite as well as a basic macro implementation


> scheme@(guile-user)> `(1 2 3 . ,%nil)
> (1 2 3)
> (is %nil in Scheme a variable because it needs the unquote?)

Scheme's end-of-list has the read syntax `()'. Elisp's nil has no read
syntax, to Scheme. If you want to get it in Scheme, you have to do so
via a variable.

> scheme@(guile-user)> (null? %nil)
> #f

This is a bug with the VM.

> scheme@(guile-user)> (equal? %nil (cdr (list 1)))
> #f

Hmmmmmmm. It's not clear that nil and null are equal?. Probably they
should be. Should they be eqv ? I wonder.

> It would be cool to teach Guile somehow to treat %nil as the "standard"
> end-of-list value, such that both of these queries would optimally
> return true.

No, they need to be different. Otherwise (if (cdr '(a)) 'b 'c) would
give 'c, not 'b.

> At least, is there some way to construct lists terminated by %nil
> using something like the list primitive?

It would need to be something you implement as part of the emacs

Otoh, (cons* a b c %nil) will do what you want.

> Other things needed would be for instance terminating rest-arguments
> by %nil rather than '() and the like.

Hmmmmm. This is a good question. I think that, on the bytecode side, you
would have to receive the normal Scheme rest argument, then run through
it and replace the terminating '() with %nil. So when compiling
functions that take rest args, they'd have this operation as one of
their first instructions. There could be a VM op for this if necessary.

> So:  How is this handled by the interpreter?  Is there maybe some
> runtime-option to make Guile use %nil as end-of-list for lists
> constructed?  Or could we introduce some means to do so?
> If that's not a good idea because of performance or other
> considerations, I guess I'll have to implement some conversion routine
> and use that?  This on the other hand will probably hit Elisp's
> performance.

Yes it's probably a good idea to implement this conversion routine, for
now at least.

On the other other hand... can we enumerate the set of circumstances in
which we'd want to change a Scheme list to an Elisp list? Call,
obviously. Probably we want to support tail recursion in calls within
elisp, so tail calls too. Reading, but the elisp reader has to be
slightly different anyway. If it's only calls, we can do tricks in the
VM to make things faster.

But for now, just compile in a call to a runtime conversion.



reply via email to

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