chicken-users
[Top][All Lists]
Advanced

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

[Chicken-users] Anaphoric IF


From: Felix Winkelmann
Subject: [Chicken-users] Anaphoric IF
Date: Mon, 24 Nov 2003 13:26:27 +0100
User-agent: Opera7.21/Win32 M2 build 3218

Hello!

I frequently write code like this;

(or (and-let* ([a (member x y)]) (cadr a))
    ...)

or:

(cond [(assq x y) => cdr] [else #f])

So what about this:

(if* (member x y) (cadr it) ...)

(if* (assq x y) (cdr it) #f)

The straightforward expansion would be:

(let ([it CONDITION])
  (if it
      IFPART
      ELSEPART) )

but another alternative might be:

(let ([TMP CONDITION])
  (if TMP
      (let ([it TMP])
        IFPART)
      ELSEPART) )

(here the ELSEPART still has access to any enclosing `it',
since otherwise it would be #f,m anyway)

Pointless or practical?


cheers,
felix




reply via email to

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