Re: truth of %nil

2009-09-17 Thread Neil Jerram
Mark H Weaver writes: > Certainly writing (a b c . #nil) as (a b c) would be most natural and > convenient, and maybe it's the best compromise, but I'm not entirely > sure it's safe. > > What if we have an association list mapping symbols to booleans that > came from elisp? Such a alist might lo

Re: truth of %nil

2009-09-02 Thread Mark H Weaver
Neil Jerram wrote: > > One more thing: scheme code can reasonably expect to "write" a list of > > simple values and then "read" it back in. But now, lists might be > > terminated by %nil instead of '(). Therefore, I think "read" needs to > > be able to read SCM_LISP_NIL in whatever form we "write

Re: truth of %nil

2009-09-01 Thread Neil Jerram
Mark H Weaver writes: > What about scm_is_bool? I'm tempted to suggest that it should work > the same way as "boolean?" within scheme, whatever that may be. I > tend to think they ought to treat %nil as boolean, though I'm less > sure of this than about scm_is_true/false/null. It's the right t

Re: truth of %nil

2009-09-01 Thread Neil Jerram
Mark H Weaver writes: > On Sun, Aug 30, 2009 at 12:13:59PM +0100, Neil Jerram wrote: >> Mark H Weaver writes: >> >> > This numbering has the nice properties that 0 is #f. >> >> Just to be clear: will this mean that (SCM_BOOL_F == 0) ? As things >> stand I don't think it will, because SCM_MAKI

Re: truth of %nil

2009-08-31 Thread Ken Raeburn
On Aug 31, 2009, at 17:59, Ludovic Courtès wrote: I think I'm mildly in favor of keeping all-bits-zero as an invalid representation. But, if it's a huge win for BDW-GC, maybe it's worth it. As discussed in my other message, it would actually be harmful. Then I'm definitely in favor of keepin

Re: truth of %nil

2009-08-31 Thread Ludovic Courtès
Hi, Ken Raeburn writes: > I kind of assumed that making all-bits-zero an invalid value was a > conscious choice by the Guile (or SCM?) designers which wasn't likely > to be revisited. It is, after all, a fairly easy way of highlighting > a certain class of uninitialized-value problems -- choosi

Re: truth of %nil

2009-08-30 Thread Ken Raeburn
On Aug 30, 2009, at 07:13, Neil Jerram wrote: Mark H Weaver writes: This numbering has the nice properties that 0 is #f. Just to be clear: will this mean that (SCM_BOOL_F == 0) ? As things stand I don't think it will, because SCM_MAKIFLAG shifts and adds 0x04. Just checking this because Ludovi

Re: truth of %nil

2009-08-30 Thread Mark H Weaver
On Sun, Aug 30, 2009 at 12:13:59PM +0100, Neil Jerram wrote: > Mark H Weaver writes: > > > This numbering has the nice properties that 0 is #f. > > Just to be clear: will this mean that (SCM_BOOL_F == 0) ? As things > stand I don't think it will, because SCM_MAKIFLAG shifts and adds > 0x04. Ye

Re: truth of %nil

2009-08-30 Thread Mark H Weaver
Neil wrote: > > I would like to argue that the definitions of scm_is_false, > > scm_is_true, and scm_is_null should indeed be changed to test for > > %nil. > > OK, thanks to your arguments, I now agree with this. Excellent! What about scm_is_bool? I'm tempted to suggest that it should work the

Re: truth of %nil

2009-08-30 Thread Neil Jerram
"Mark H. Weaver" writes: > I found one thorny use of scm_is_bool and scm_is_null, and request > your collective wisdom: > > scm_class_of() in goops.c tries to determine the class of a scheme > value. If scm_is_bool returns true, it's classified as > scm_class_boolean, and if scm_is_null returns

Re: truth of %nil

2009-08-30 Thread Neil Jerram
Mark H Weaver writes: > This numbering has the nice properties that 0 is #f. Just to be clear: will this mean that (SCM_BOOL_F == 0) ? As things stand I don't think it will, because SCM_MAKIFLAG shifts and adds 0x04. Just checking this because Ludovic said recently that (SCM_BOOL_F == 0) would

Re: truth of %nil

2009-08-30 Thread Neil Jerram
Hi Mark! Mark H Weaver writes: > I would like to argue that the definitions of scm_is_false, > scm_is_true, and scm_is_null should indeed be changed to test for > %nil. OK, thanks to your arguments, I now agree with this. > Do a grep-find in the tree for uses of these macros. I think you'll >

Re: truth of %nil

2009-07-23 Thread Andy Wingo
On Fri 03 Jul 2009 17:32, Mark H Weaver writes: > It might be worth considering a build-time option to disable %nil, so > that it's possible to build a version of guile which doesn't pay this > price. You probably found it, but Guile does have such an option. (Jeez, I didn't think I'd ever find

Re: truth of %nil

2009-07-08 Thread Mark H. Weaver
I've discovered two more tests that can be optimized using the same bit masking tricks: scm_is_bool and scm_is_bool_or_lisp_nil (newly created). Since SCM_BOOL_F and SCM_BOOL_T differ by only one bit, that one is easy. The other one can be implemented the same way as scm_is_lisp_false in my last

Re: truth of %nil

2009-07-08 Thread Ludovic Courtès
Hi, Neil Jerram writes: > There are ways of writing compile time asserts; see > http://www.jaggersoft.com/pubs/CVu11_3.html for some. I don't know > how portable these all are, but at work we use the case label one, and > that seems to be good on common platforms. Gnulib's `verify' module prov

Re: truth of %nil

2009-07-07 Thread Mark H Weaver
Having thought more about optimizing %nil handling, it occurs to me that we will also want boolean tests from within lisp to be optimized. >From lisp, three values are considered to be false: #f, '(), and %nil. We can use the same bit-masking trick to do these tests quickly if we make sure that th

Re: truth of %nil

2009-07-06 Thread Mark H Weaver
On Mon, Jul 06, 2009 at 10:46:11PM +0100, Neil Jerram wrote: > Assuming you are planning to work on the code changes for this, we > will need copyright assignment papers from you. Will that be OK? Yes, certainly. I live in the Boston area, so I'll stop by the FSF office and take care of that soo

Re: truth of %nil

2009-07-06 Thread Neil Jerram
Mark H Weaver writes: > Below is a proposal for how to make boolean tests and end-of-list > tests faster and more compact, by renumbering the representations for > SCM_ELISP_NIL, SCM_EOL, SCM_UNDEFINED, and SCM_EOF_VAL. Interesting. I haven't looked at every detail but I'm happy to go along wit

Re: truth of %nil

2009-07-05 Thread Mark H Weaver
I would like to argue that the definitions of scm_is_false, scm_is_true, and scm_is_null should indeed be changed to test for %nil. Do a grep-find in the tree for uses of these macros. I think you'll find that the majority of places where they are used should also be checking for %nil, but they a

Re: truth of %nil

2009-07-05 Thread Andy Wingo
On Sun 05 Jul 2009 03:41, Mark H Weaver writes: > Below is a proposal for how to make boolean tests and end-of-list > tests faster and more compact, by renumbering the representations for > SCM_ELISP_NIL, SCM_EOL, SCM_UNDEFINED, and SCM_EOF_VAL. That looks like great work, Mark!! I don't think

Re: truth of %nil

2009-07-04 Thread Mark H Weaver
Below is a proposal for how to make boolean tests and end-of-list tests faster and more compact, by renumbering the representations for SCM_ELISP_NIL, SCM_EOL, SCM_UNDEFINED, and SCM_EOF_VAL. But first, I decided to quantify the increase in code size testing against two constants instead of one, b

Re: truth of %nil

2009-07-03 Thread Mark H Weaver
Thank you, Neil, for the pointers to earlier discussions of this subject. Having read them, I've been convinced that the %nil approach is reasonable and probably the best way to deal with elisp<->scheme interoperability. Though, like you, I was not willing to easily accept two false values and tw

Re: truth of %nil

2009-07-02 Thread Neil Jerram
Mark H Weaver 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

Re: truth of %nil

2009-07-02 Thread Ludovic Courtès
Hi, Mark H Weaver writes: > I've been considering writing a python compiler for guile. 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. [...] > So how abou

Re: truth of %nil

2009-07-02 Thread Mark H Weaver
I've been considering writing a python compiler for guile. 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, shou

Re: truth of %nil

2009-07-01 Thread Neil Jerram
Daniel Kraft writes: > it seems so. Doing just a > > scheme@(guile-user)> (if %nil 1 2) > 1 > > with a recent build (of at least my elisp branch, but that did not > change anything in this respect of course) gives that answer. > > Doing ,o interp #t as Andy did however also gives the right answe

Re: truth of %nil

2009-06-30 Thread Daniel Kraft
Hi Neil, Neil Jerram wrote: Andy Wingo writes: Guile has treated %nil as false for quite some time: scheme@(guile-user)> ,o interp #t scheme@(guile-user)> (if %nil 1 2) $1 = 2 I'm sorry... you're completely right. Brain storm on my part. But then I don't understand the cause o

Re: truth of %nil

2009-06-30 Thread Neil Jerram
Andy Wingo writes: > On Mon 29 Jun 2009 23:44, Neil Jerram writes: > >> Andy Wingo writes: >> >>> scheme@(guile-user)> (if %nil 1 2) >>> 1 >>> >>> #define scm_is_false(x) (scm_is_eq ((x), SCM_BOOL_F) || SCM_NILP (x)) > >> Seems wrong to me. In Scheme #f should be the only false val

Re: truth of %nil

2009-06-29 Thread Andy Wingo
On Mon 29 Jun 2009 23:44, Neil Jerram writes: > Andy Wingo writes: > >> scheme@(guile-user)> (if %nil 1 2) >> 1 >> >> #define scm_is_false(x) (scm_is_eq ((x), SCM_BOOL_F) || SCM_NILP (x)) > Seems wrong to me. In Scheme #f should be the only false value. > What's the argument for %n

Re: truth of %nil

2009-06-29 Thread Neil Jerram
Andy Wingo writes: > Hi all, > > Daniel came up with an interesting test case: > > scheme@(guile-user)> (if %nil 1 2) > 1 > > We could fix this transparently by changing scm_is_false in boolean.h > from: > > #define scm_is_false(x) scm_is_eq ((x), SCM_BOOL_F) > > to > > #define sc

truth of %nil

2009-06-29 Thread Andy Wingo
Hi all, Daniel came up with an interesting test case: scheme@(guile-user)> (if %nil 1 2) 1 We could fix this transparently by changing scm_is_false in boolean.h from: #define scm_is_false(x) scm_is_eq ((x), SCM_BOOL_F) to #define scm_is_false(x) (scm_is_eq ((x), SCM_BOOL_F) ||