Hello,

Sometimes I want the convenience of anamorphic 'if', but the version which always uses the symbol 'it' seems funny.

I'm experimenting with a variant; here's an example:

> (if 10 is it
      it
      20)
10
>

For kicks, I also added the '=>' keyword which indicates behaviour like 'cond':

> (if 10 =>
      list
      20)
(10)
>

I think the 'is' keyword could be retrofitted to 'cond' so that there's some symmetry between this it and this 'if'.

Basic idea:

(import (rename (rnrs) (if rnrs:if)))

(define-syntax if

  (syntax-rules (is =>)

    ( (if test is var a b)

      (let ((var test))

        (rnrs:if var a b)) )

    ( (if test => a b)

      (let ((val test))

        (rnrs:if val (a val) b)) )

    ( (if test a b)

      (rnrs:if test a b) )))

Another idea for the keyword is 'as'.

Ed

Reply via email to