From: Neil Jerram <neil@ossau.uklinux.net>
To: Mark H Weaver <mhw@netris.org>
Cc: Andy Wingo <wingo@pobox.com>, guile-devel <guile-devel@gnu.org>
Subject: Re: truth of %nil
Date: Thu, 02 Jul 2009 23:50:58 +0100 [thread overview]
Message-ID: <877hyqk8bx.fsf@arudy.ossau.uklinux.net> (raw)
In-Reply-To: <20090702142823.GA1401@fibril.netris.org> (Mark H. Weaver's message of "Thu\, 2 Jul 2009 10\:28\:25 -0400")
Mark H Weaver <mhw@netris.org> writes:
> I've been considering writing a python compiler for guile.
Great!
> For python
> (and others) there are several values considered to be false, such as
> 0 and various empty collections, and so a different approach will have
> to be taken to this problem.
>
> If we want guile to handle many different languages, should we not try
> to find an approach to "false-ness" that handles many languages, and
> not just a few?
There's been loads of prior discussion on this subject. Here are
pointers to some of that.
http://sourceware.org/ml/guile/1999-07/msg00251.html
http://sourceware.org/ml/guile/1998-07/msg00187.html
http://lists.gnu.org/archive/html/guile-devel/2001-09/msg00140.html
http://lists.gnu.org/archive/html/guile-devel/2001-11/msg00016.html
> It seems to me that some code might misbehave in the presence of two
> values which are both null? but not eq? to each other.
Example? (This seems quite unlikely to me.)
> Also, it seems more consistent to use the same strategy for handling
> various languages' notions of false-ness.
>
> To my mind, we should not be changing the data (which only works for
> lisp), but rather the constructs that decide whether a given value is
> false.
>
> So how about having elisp `if' and `cond' compile not to scheme `if'
> and `cond', but rather to scheme `elisp-if' and `elisp-cond'? Or
> perhaps compile `(if c a b)' to `(if (elisp-true? c) a b)'.
>
> This approach, unlike the %nil approach, will work for other languages
> too.
Certainly this is a possible approach. In what's been done so far,
and what we do in future, I don't think there are any arguments that
trump all the other considerations. It's just a matter of balancing
performance, robustness, and so on. If more non-Lisp-like languages
are added, your consideration of cross-language consistency would gain
more weight.
On a matter of detail, I don't understand your statement that the
current %nil approach won't work for other languages. As the query
that started this thread shows, it is perfectly possible to code a new
language (VM-Scheme, in this case) in which %nil is true.
If I understand it correctly, a key point of the thinking up till now
is that Elisp is a special case because it is so `tantalizingly
similar' (as Jim put it) to Scheme. This similarity creates the
possibility of passing data directly between Elisp and Scheme, and the
fact that Guile Scheme treats %nil as both #f and '() follows from
that; otherwise it would be necessary to convert data as it passes
from one language to the other. In other words - a performance point.
Now we have Brainfuck and ECMAScript too, but I don't know if they are
complex enough to cast significant doubt on the existing balance. (To
be honest, I'm not sure if that's true for ECMAScript, I need to look
at Andy's code.)
Python on the other hand would be plenty complex enough, and I assume
it has arbitrarily complex data structures. How do you envisage data
transfer working between Python and other languages?
> It also means that Guile's normal `if' and `cond' won't be slowed down
> by having to check for two values instead of one. That overhead may
> be insignificant now, but when we have a native code compiler, it will
> be quite significant in code size at least, even if the
> representations of %nil and #f differ by only one bit.
Do you really think so? Just because of two compare operations
instead of one? Perhaps I'm misunderstanding you.
> On Mon, Jun 29, 2009 at 10:44:54PM +0100, Neil Jerram wrote:
>> Seems wrong to me. In Scheme #f should be the only false value.
>> What's the argument for %nil being false in Scheme code?
(Just for the record, my statement here was wrong, and I've since
corrected it.)
Regards,
Neil
next prev parent reply other threads:[~2009-07-02 22:50 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-29 21:12 truth of %nil Andy Wingo
2009-06-29 21:44 ` Neil Jerram
2009-06-29 22:11 ` Andy Wingo
2009-06-30 22:22 ` Neil Jerram
2009-07-01 6:45 ` Daniel Kraft
2009-07-01 21:54 ` Neil Jerram
2009-07-05 13:07 ` Mark H Weaver
2009-08-30 11:07 ` Neil Jerram
2009-08-30 14:11 ` Mark H Weaver
2009-09-01 22:00 ` Neil Jerram
2009-09-02 15:57 ` Mark H Weaver
2009-09-17 21:21 ` Neil Jerram
2009-07-02 14:28 ` Mark H Weaver
2009-07-02 14:50 ` Ludovic Courtès
2009-07-02 22:50 ` Neil Jerram [this message]
2009-07-03 15:32 ` Mark H Weaver
2009-07-05 2:41 ` Mark H Weaver
2009-07-05 9:19 ` Andy Wingo
2009-07-07 11:14 ` Mark H Weaver
2009-07-08 13:17 ` Mark H. Weaver
2009-08-30 11:20 ` Neil Jerram
2009-08-30 11:13 ` Neil Jerram
2009-08-30 14:15 ` Mark H Weaver
2009-09-01 21:50 ` Neil Jerram
2009-08-30 22:01 ` Ken Raeburn
2009-08-31 21:59 ` Ludovic Courtès
2009-08-31 23:39 ` Ken Raeburn
2009-08-31 21:55 ` SCM_BOOL_F == 0 and BDW-GC Ludovic Courtès
2009-09-17 22:00 ` Neil Jerram
2009-09-17 22:28 ` Ludovic Courtès
2009-09-18 20:51 ` Neil Jerram
2009-09-20 17:21 ` Ludovic Courtès
2009-09-20 21:03 ` Neil Jerram
2009-09-20 21:36 ` Ludovic Courtès
2009-07-06 21:46 ` truth of %nil Neil Jerram
2009-07-06 23:54 ` Mark H Weaver
2009-07-08 8:08 ` Ludovic Courtès
2009-07-23 21:12 ` Andy Wingo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877hyqk8bx.fsf@arudy.ossau.uklinux.net \
--to=neil@ossau.uklinux.net \
--cc=guile-devel@gnu.org \
--cc=mhw@netris.org \
--cc=wingo@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).