This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: why undefined return values?
- To: Tom Burdick <tfb at u dot washington dot edu>
- Subject: Re: why undefined return values?
- From: PILCH Hartmut <phm at a2e dot de>
- Date: Thu, 20 Jan 2000 22:21:51 +0100 (CET)
- cc: guile at sourceware dot cygnus dot com
> > (let (eof match str)
> > (if
> > (and
> > (not (setq eof (eof))
> > (setq match (find-match regexp))
> > (setq str (car match))
> > )
> > ...
> > )
>
> When I learned Lisp/scheme, I was taught to write things like that as:
> (let* ((eof (eof))
> (match (find-match regexp))
> (str (cdr match)))
> (if
> (and (not eof) match str)
> ...
> ))
This doesn't work for the intended purpose, because find-match should not
be evaluated at all, if an eof is encountered. Generally speaking, there
is no reason why scoping an binding should coincide. Often the scope, in
which a variable is needed is quite large, and initialisation to a useful
value occurs deep inside some nested logic.
In my 'textcoding' script submitted earlier, the lack of a setq motivated
me to look for and find some good alternatives and even to use some
unelegant let bindings, but still I couldn't always avoid writing
(begin (set! var val) val)
--
phm