unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Daniel Kraft <d@domob.eu>
To: Neil Jerram <neil@ossau.uklinux.net>
Cc: Clinton Ebadi <clinton@unknownlamer.org>,
	Andy Wingo <wingo@pobox.com>, guile-devel <guile-devel@gnu.org>
Subject: Re: %nil once again
Date: Fri, 31 Jul 2009 07:03:09 +0200	[thread overview]
Message-ID: <4A727B0D.6080303@domob.eu> (raw)
In-Reply-To: <87d47hyhoz.fsf@arudy.ossau.uklinux.net>

Hi Neil,

Neil Jerram wrote:
>> The only downside I can see to this is that if code were
>> to be ported from elisp to Scheme there would now be code that assumed a
>> '() return as false when #f would be false, but this could be fixed
>> using a predicate like elisp-false? (or null-or-false? or
>> ... something).
> 
> I don't like that at all!
> 
> In my view, the only reasonable alternative solution above is the one
> that would work by translating data passing between Elisp and Scheme.
> The theoretical argument against that is that such translation could
> be arbitrarily complex, and so have an unbounded performance cost, but
> in practice I imagine that would almost never be the case.  Also there
> is the point that languages other than Elisp will _require_ data
> translation, and why should we make Elisp a special case?  Hence I
> wouldn't rule out the possibility of switching to this design in
> future; and then we could, as you say, make nil==() and remove most
> elisp special cases from the libguile core.

I agree here; though I think we should get translation to a minimum as 
much as possible; for instance, I still think the Guile core should 
treat %nil as false and empty list if asked for.  This does not hurt 
Scheme, as %nil does not occur there, but it would allow us to just use 
TreeIL conditionals and the like without having to translate here.

On the other hand, if we want elisp semantics as faithfully as possible, 
we need to translate the way from Guile primitives to elisp code. 
Currently I'm already doing this for booleans; for instance, the = 
built-in of emacs is defined something like:

(lambda (a b)
   (if (= a b)
     t
     %nil))

so that the "false" value is really %nil.  On a later thought, this 
might be the real reason why my "tight while loop" performed worse than 
the Scheme version in the performance test.  But I don't see a way how 
to get around this, unfortunatly; except if we just assume that the 
elisp user won't test a false value for (eq value nil) but just use it 
as boolean in conditionals, too, so it does not matter if the value is 
%nil or #f.

The same applies to lists...  In general, one can write probably most 
elisp code without having to really care if the tail of a rest argument 
or the result from the list built-in or some quotation-expression is 
%nil or '() (and should actually check with null instead of (eq nil), I 
think).  At the moment it is like that, there's no '() <--> %nil 
translation happening by now.  As long as libguile/VM gets the patch to 
accept %nil as end-of-list (as the interpreter already does), one can 
still do (cons 'a (cons 'b nil)) in elisp and get the expected result...

I'm still not sure if we should actually do data translation from Scheme 
(Guile built-ins) to elisp user code or not...  But probably we should 
just do it and the performance hit will not be too painful.

Daniel

-- 
Done:  Arc-Bar-Cav-Ran-Rog-Sam-Tou-Val-Wiz
To go: Hea-Kni-Mon-Pri




  reply	other threads:[~2009-07-31  5:03 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-16 13:47 %nil once again Daniel Kraft
2009-07-17  7:59 ` Neil Jerram
2009-07-17  9:02   ` Daniel Kraft
2009-07-17 14:20     ` Andreas Rottmann
2009-07-19 18:28     ` Neil Jerram
2009-07-19 19:44       ` Daniel Kraft
2009-07-19 20:10         ` Neil Jerram
2009-07-20  3:33           ` Ken Raeburn
2009-07-20  8:12             ` Daniel Kraft
2009-07-20  9:15               ` Ken Raeburn
2009-07-23 22:18             ` Andy Wingo
2009-07-20 18:17 ` Clinton Ebadi
2009-07-30 21:38   ` Neil Jerram
2009-07-31  5:03     ` Daniel Kraft [this message]
2009-07-23 20:35 ` Andy Wingo
2009-07-24  6:20   ` Daniel Kraft
2009-07-30 21:50   ` Neil Jerram
2009-07-31  5:05     ` Daniel Kraft

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=4A727B0D.6080303@domob.eu \
    --to=d@domob.eu \
    --cc=clinton@unknownlamer.org \
    --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).