[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [shift and reset, plus] "while"

From: Wolfgang J Moeller
Subject: Re: [shift and reset, plus] "while"
Date: Wed, 13 Apr 2011 16:56:50 +0200 (CEST)

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 .

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

> > (c) to only take a single (call-with-prompt)
> Why?  It's true that the optimizer doesn't live up to its name yet, but
> it should be trivial to elide one or the other if the prompt tag is only
> referenced by the <prompt> form.

Just for simplification of the macro - it's plain overkill to create two 
Nothing to do with the optimizer per se; my note only relates to the fact that
the (promised) optimization ought to work just as well with the single prompt.

> > (d) to correct a buglet that currently transforms the non-operator 
> > `continue'
> >     into a function of arbitrarily many (as opposed to zero)
> >     arguments.
> I have not seen this bug.  Do you have code that can reproduce it with
> stable-2.0 ?

No code - it's a buglet w/o much consequence - from ice-9/boot-9.scm :

;;; {While}
(define-syntax while
  (define-syntax #,(datum->syntax #'while 'continue)
    (lambda (x)
      (syntax-case x ()
         #'(abort-to-prompt continue-tag))
        ((_ . args)             ; <<<<< wjm: no argumenta allowed - OK
         (syntax-violation 'continue "too many arguments" x))
         #'(lambda args         ; <<<<< wjm: arguments allowed - WHY??
             (apply abort-to-prompt continue-tag args))))))

Stand-alone fix:

        ((_ . args)             ; no arguments allowed
         (syntax-violation 'continue "too many arguments" x))
         #'(lambda ()           ; also, zero arguments
             (abort-to-prompt continue-tag)))))

Best regards,

Wolfgang J. Moeller, Tel. +49 551 47361, wjm<AT>
37085 Goettingen, Germany | Disclaimer: No claim intended! -+--------

reply via email to

[Prev in Thread] Current Thread [Next in Thread]