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

Re: [Scheme-reports] when and unless

leppie scripsit:

> Take for example:
> (define (foo bar)
>   (unless (list? bar) (error 'foo "not a list" foo))
>   (map values bar))
> Now applying the above with say (foo 1) will raise an error. If I set
> my debugger to break inside ERROR, I get a nice complete stacktrace,
> including the caller, IOW FOO.
> Now take what is suggested:
> (define (foo bar)
>   (if (not (list? bar)) (error 'foo "not a list" foo)
>                            (map values bar)))
> Now inside ERROR, you do not have 'lost' the caller (FOO) as the
> application of ERROR was a tail call. Given the context of FOO's
> application that may also be a tail call, and so on.

I would certainly want the last form in WHEN/UNTIL to be a tail position.
The obvious implementation ((when x . y) (if x (begin . y))) would certainly
make it so.

John Cowan  cowan@x  http://ccil.org/~cowan
If I have seen farther than others, it is because I was standing on
the shoulders of giants.
        --Isaac Newton

Scheme-reports mailing list