This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: why undefined return values?


> >       (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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]