From: Andy Wingo <wingo@pobox.com>
To: ludo@gnu.org (Ludovic Courtès)
Cc: guile-devel@gnu.org
Subject: Re: early termination for `map'
Date: Thu, 05 May 2011 20:40:40 +0200 [thread overview]
Message-ID: <m3iptpvvmf.fsf@unquote.localdomain> (raw)
In-Reply-To: <8739kt2jxb.fsf@gnu.org> ("Ludovic Courtès"'s message of "Thu, 05 May 2011 18:26:08 +0200")
On Thu 05 May 2011 18:26, ludo@gnu.org (Ludovic Courtès) writes:
> Andy Wingo <wingo@pobox.com> writes:
>
>> If you call `map' or `for-each' with more than one list, our versions of
>> these operators will detect if the lists are of unequal length, and
>> throw an error in that case.
>>
>> However, SRFI-1 has long provided an extension to this, to allow for
>> early termination when any of the lists runs out. R6RS adopted this,
>> and it looks like R7RS will ratify that.
>>
>> So perhaps it's time for us to change as well.
>
> To change the default ‘map’ & ‘for-each’ to do like SRFI-1’s, right?
Yeah, that was the proposal; but the argument is a bit weaker, now that
I found that the R6RS did not go with this change. So I don't really
know.
The reason I was thinking of doing this is because it turns out to help
performance to have map in scheme, at this point; or at least not hurt
it, and things will get better when we grow an optimizer.
So I implemented map in Scheme, with circularity detection and all, only
to find strange errors in the ecmascript compiler (!). Turns out those
errors happened when loading goops, because it tried to extend a
primitive generic, but map wasn't a primitive any more, and instead of
failing nicely it corrupted memory.
>> This would also allow us to get rid of the hack in srfi-1.c in which,
>> when and if GOOPS gets loaded, srfi-1 extends the `map' and `for-each'
>> primitive generics with its own early-termination code, which in effect
>> gives early termination to every `map' user, regardless of whether that
>> module has imported srfi-1 or goops. Sometimes I think that Mikael put
>> the Oops in Goops for a reason ;-)
>
> Heh. :-)
>
> Code not using GOOPS can tell the difference between the default and
> SRFI-1 versions, and it can arrange to explicitly use one or the other.
> So changing the default versions would be an incompatibility—arguably
> not an important one, but still maybe enough to wait until 2.2?
Yeah, perhaps you are right, and the srfi-1 / goops interaction should
probably get some other resolution -- like merge-generics on import, or
something.
Thanks for your thoughts,
Andy
--
http://wingolog.org/
next prev parent reply other threads:[~2011-05-05 18:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-05 15:24 early termination for `map' Andy Wingo
2011-05-05 15:56 ` Noah Lavine
2011-05-05 16:26 ` Ludovic Courtès
2011-05-05 18:40 ` Andy Wingo [this message]
2011-05-05 20:21 ` Ludovic Courtès
2011-05-05 21:12 ` Andy Wingo
2011-05-06 15:41 ` Ludovic Courtès
2011-05-08 15:05 ` ‘map’ and ‘for-each’ written in Scheme Ludovic Courtès
2011-05-08 15:31 ` Andy Wingo
2011-05-05 18:27 ` early termination for `map' 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=m3iptpvvmf.fsf@unquote.localdomain \
--to=wingo@pobox.com \
--cc=guile-devel@gnu.org \
--cc=ludo@gnu.org \
/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).