unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Mark H Weaver <mhw@netris.org>
To: Neil Jerram <neil@ossau.uklinux.net>
Cc: Andy Wingo <wingo@pobox.com>, Daniel Kraft <d@domob.eu>,
	guile-devel <guile-devel@gnu.org>
Subject: Re: truth of %nil
Date: Sun, 30 Aug 2009 10:11:00 -0400	[thread overview]
Message-ID: <20090830141100.GA2255@fibril.netris.org> (raw)
In-Reply-To: <87my5hy2yv.fsf@arudy.ossau.uklinux.net>

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 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 thing
for type-checking an argument that is expected to be boolean, which
seems to be fairly common in guile.  More complex code that is
dispatching on type (such as the aforementioned GOOPS code) will in
general have to be fixed to take into account that %nil is both a
boolean and a list.

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" it in.  I'll
let someone more knowledgable about guile reader issues decide what
that form should be.  Currently we write it as "#nil".

> > If, in a particular use, it
> > can be proved statically that the value was not created by an elisp
> > function (which we can almost never prove), then that is a case where
> > we can use some faster test.  [...]
>
> [...]
> 
> This is also something that could (potentially!) be optimized at
> runtime or by the compiler (reminds me of the class of calls where
> type checking could be eliminated if the compiler can prove that
> objects will always be of the required type).

Yes, I've also given this some thought.  If we were using C++ (I'm
very glad we're not, btw!) then I'm pretty sure we could use the type
system to mark certain functions as never returning %nil, and then
arrange to optimize away the %nil checks in those cases, but I can't
think of a way to do it with C, even with GCC's extensions.  Maybe, if
we can develop a reasonable proposal, we can get sufficient
functionality added to GCC.

> So, if you would be happy to do so, can I suggest that you rework your
> patches so that they also make (and then assume, obviously) the
> scm_is_false/true/bool/null change, and incorporate my other comments?

I will gladly do so.

> It would also be more convenient - and better for giving you your
> deserved attribution - if you could submit them as Git patches.  Would
> that be possible?

Will do.

> Also, we will need documentation of the new APIs, and to explain the
> overall concept; and a NEWS entry; and maybe a couple of tests to
> check where data that includes %nil is passed to some of the fixed
> functions.  Would you be willing to prepare all those too?

Yes, certainly.

> > One category of place where these could be used is code dealing with
> > data structures created internally by the evaluator -- though I'm not
> > very familiar with guile's internals, so I don't know how common these
> > data structures are, if indeed they exist at all.
> 
> Yes, indeed.  In the updated patch(es), I suggest that you mark the
> cases that you are not sure about, then I and other developers can
> help work out what kind of check they should be doing.

Indeed, some of the usage cases are difficult for me to evaluate, so
your help will be much appreciated!

Also, I signed my copyright assignment papers a while ago, and the
relevant file on fencepost has been updated accordingly.

   Best,
    Mark




  reply	other threads:[~2009-08-30 14:11 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 [this message]
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
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=20090830141100.GA2255@fibril.netris.org \
    --to=mhw@netris.org \
    --cc=d@domob.eu \
    --cc=guile-devel@gnu.org \
    --cc=neil@ossau.uklinux.net \
    --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).