guile-user
[Top][All Lists]
Advanced

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

Re: C++ declaration style programming?


From: Thien-Thi Nguyen
Subject: Re: C++ declaration style programming?
Date: Thu, 22 Jan 2004 03:24:46 +0100

   From: Viktor Pavlenko <address@hidden>
   Date: Wed, 21 Jan 2004 10:41:09 -0500

   Using side effects to re-bind a variable within the binding
   expression of let* sounds like cheating :)

well, here's another way to "cheat", i suppose:

(defmacro let-false (bindings . body)
  `(let ,(map (lambda (b) (list b #f)) bindings) ,@body))

usage is something like:

(let-false (a b c) 1) => 1
(let-false (a b c) b) => #f
(let-false (a b c)
  (set! a 2)
  (set! b (+ a (* a a)))
  (set! a (+ b (* b b)))
  (list a (not c))) => the answer to life the universe and everything?

(let-false (a b c) d)
=| ERROR: Unbound variable: d
   ABORT: (unbound-variable)

if "false" is too much of a downer, you can munge to taste of course.
"let-pessimistic", "let-oh-why-bother-i-have-a-brain-the-size-of-a-planet".

thi




reply via email to

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