Re: [Scheme-reports] when and unless
John Cowan
(19 May 2011 21:42 UTC)
|
Re: [Scheme-reports] when and unless
Pierpaolo Bernardi
(20 May 2011 09:32 UTC)
|
Re: [Scheme-reports] when and unless
Alex Queiroz
(20 May 2011 09:38 UTC)
|
Re: [Scheme-reports] when and unless
Alaric Snell-Pym
(23 May 2011 10:36 UTC)
|
Re: [Scheme-reports] when and unless
Eli Barzilay
(23 May 2011 10:41 UTC)
|
Re: [Scheme-reports] when and unless
Aaron W. Hsu
(23 May 2011 22:50 UTC)
|
Re: [Scheme-reports] when and unless
Pierpaolo Bernardi
(24 May 2011 08:25 UTC)
|
Re: [Scheme-reports] when and unless
Emmanuel Medernach
(24 May 2011 08:37 UTC)
|
Re: [Scheme-reports] when and unless
Alaric Snell-Pym
(24 May 2011 09:06 UTC)
|
Re: [Scheme-reports] when and unless
Aaron W. Hsu
(24 May 2011 18:57 UTC)
|
Re: when and unless
Arthur A. Gleckler
(24 May 2011 19:35 UTC)
|
Re: [Scheme-reports] when and unless leppie (24 May 2011 08:51 UTC)
|
Re: [Scheme-reports] when and unless
Pierpaolo Bernardi
(24 May 2011 09:06 UTC)
|
Re: [Scheme-reports] when and unless
leppie
(24 May 2011 09:23 UTC)
|
Re: [Scheme-reports] when and unless
John Cowan
(24 May 2011 14:51 UTC)
|
Re: [Scheme-reports] when and unless
Pierpaolo Bernardi
(24 May 2011 14:57 UTC)
|
Re: [Scheme-reports] when and unless
Aaron W. Hsu
(24 May 2011 18:56 UTC)
|
On Tue, May 24, 2011 at 10:25 AM, Pierpaolo Bernardi <olopierpa@gmail.com> wrote: > I use them, sometimes, when rewriting in scheme an algorithm > written in imperative style in a foreign language. For example, > when taking an algorithm from a book. > > Sometimes it's worth the time to translate the code in good style, > and sometimes the time is missing. Luckily, with scheme we have > the choice. > > Nevertheless, I'd prefer not to have these macros in the standard. > And I'd strongly prefer not to have them in WG1 scheme. There are good reasons to use UNLESS and WHEN, especially in terms of error checking. 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. In my specific case (and might be the same with other implementations) I generate a stacktrace (if enabled for the session) for every raised error. Using the first approach allows me to go up a (stack)frame and inspect the FOO procedure accordingly. My 2 cents. Cheers leppie -- http://codeplex.com/IronScheme http://xacc.wordpress.com _______________________________________________ Scheme-reports mailing list Scheme-reports@scheme-reports.org http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports