[bitc-dev] CLEANUP: Two-legged "if"

Kevin Reid kpreid at mac.com
Thu Jul 17 09:00:01 CDT 2008


On Jul 17, 2008, at 8:54, Jonathan S. Shapiro wrote:

> If anybody has strong objections, we need to hear them!

This is not an objection, but a "have you thought about this?".

> As we have been writing code, I find increasingly that I want to be  
> able
> to use a two-legged if. In functional programs this form has fairly
> limited value, but in stateful programs it is a very common idiom. ...

> a derived form returning unit:
>
>  (if e-test e-then)  =>
>  (if e-test (begin e-then ()) ())

Have you considered instead introducing a separate operator with an  
implicit begin, allowing multiple forms in the body, since this is  
often useful in such imperative code?

Common Lisp calls this WHEN.

(when e-test e-then*)  =>
(if e-test (begin e-then* ()) ())

(using * to denote repetition; I don't know your preferred notation)

-- 
Kevin Reid                            <http://homepage.mac.com/kpreid/>




More information about the bitc-dev mailing list