unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Andy Wingo <wingo@pobox.com>
To: Wolfgang J Moeller <wjm@heenes.com>
Cc: bug-guile@gnu.org, guile-devel <guile-devel@gnu.org>
Subject: Re: [shift and reset, plus] "while"
Date: Wed, 13 Apr 2011 17:41:37 +0200	[thread overview]
Message-ID: <m3y63ef9am.fsf@unquote.localdomain> (raw)
In-Reply-To: <alpine.LNX.2.00.1104131535320.3553@gwdw03.gwdg.de> (Wolfgang J. Moeller's message of "Wed, 13 Apr 2011 16:56:50 +0200 (CEST)")

On Wed 13 Apr 2011 16:56, Wolfgang J Moeller <wjm@heenes.com> writes:

> On Wed, 13 Apr 2011, Andy Wingo wrote:
>
>>[...]
>> > I'd like to "improve" (while) as currently provided by ice-9/boot.scm
>> >
>> > (a) to always have a well-defined result
>>
>> This is a good idea; it allows `while' to be an expression, not just a
>> statement.
>>
>> > (b) to allow for (break arg ...)
>>
>> Also a good idea.
>>
>> Tricky, though; your comments indicate that you would want (break) to
>> return #t, instead of zero values.
>
> Does anyone like to _test_ for zero values? Not me.
> As regards the REPL, you still can (break (if #f #f)).
>
> Alternative: return zero values on "normal termination",
> instead of #<unspecified>, so the REPL keeps quiet then,
> as it did before. Not as handy, but at least well-defined.
>
> I don't remember if GUILE V1.6 had the return values of #f and #t,
> or if they were my own invention ... IIRC it did have (break arg)
> with a single argument. Anyway, #t is compatible with V2.0.0 .

From Guile 1.6:

    (defmacro while (cond . body)
      `(letrec ((continue (lambda () (or (not ,cond) (begin (begin ,@ body) (continue)))))
                (break (lambda val (apply throw 'break val))))
         (catch 'break
    	    (lambda () (continue))
    	    (lambda v (cadr v)))))

It did indeed happen to return #t on a normal termination, and have
(break ARG).  It has lots of other bugs though.  I would prefer (break)
to return zero values, and (while #f 1) as well, but that is
incompatible with 2.0.  Bummer.

> Not exactly tricky - see my code's prompt handler.

I didn't mean in terms of code; I meant in terms of documentation,
interface, expectations, etc...

>> > (d) to correct a buglet that currently transforms the non-operator `continue'
>> >     into a function of arbitrarily many (as opposed to zero)
>> >     arguments.

I hadn't seen this one because Mark Weaver fixed it a few weeks ago, in
ddf134cfec0d82ea9f39ddd69948c08feecb9576.

Cheers,

Andy
-- 
http://wingolog.org/



  reply	other threads:[~2011-04-13 15:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <alpine.LNX.2.00.1104041402090.26447@gwdw03.gwdg.de>
2011-04-13  9:47 ` shift and reset, plus "while" Andy Wingo
2011-04-13 14:56   ` [shift and reset, plus] "while" Wolfgang J Moeller
2011-04-13 15:41     ` Andy Wingo [this message]
2011-04-13 17:31       ` Wolfgang J Moeller
2011-04-28 12:15         ` 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=m3y63ef9am.fsf@unquote.localdomain \
    --to=wingo@pobox.com \
    --cc=bug-guile@gnu.org \
    --cc=guile-devel@gnu.org \
    --cc=wjm@heenes.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).