Just posted to comp.lang.scheme...
Hi, I'd like a let... binding to extend beyond the let. The idea
is to bind the variables to one thing or another, then pass them to
some subsequent procedure, without using set!, etc.
Something like the following python
def some_function(arg):
if some_test(arg):
var1=123
var2=456
else:
var1="xyz"
var2="abc"
do_blaaa(var1, var2)
I can think of the following in scheme but it clearly won't work:
(define (some-function arg)
(if (some-test arg)
(let ((var1 123) (var2 456)) ;bind var1 and var2 when some-test is true
(let ((var1 "xyz") (var2 "abc"))) ; else var1 and var2 = something else
(do-blaaa var1 var2) ; call do-blaaa with vars as defined in if/else above
))
Currently I have to do something like
(define (some-function arg)
(if (some-test arg)
(let ((var1 123) (var2 456)) (do-blaaa var1 var2))
(let ((var1 "xyz") (var2 "abc")) (do-blaaa var1 var2))))
where do-blaaa is called twice with exactly the same arguments.
In reality the do-blaaa is a sequence of things and/or a bit
ugly looking function call, so I'd like to only call it once, rather than
calling it independently in each (let...) expression within the (if ...)
as I currently have to do.
Any clues?
thanks
michael