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?


I have no problem with nesting let and and:

(let ((eof (eof)))
  (and (not eof) 
       (let ((match (find-match regexp)))
	 (and match
	      (let ((str (car match)))
		...)))))

However, it can certainly get tedious if needed a lot.  Paul Graham's book On Lisp defines a macro, (aif) i think to support variations on this.  In fact, the book has 13 chapters on macros.
At 10:21 PM 1/20/2000 +0100, PILCH Hartmut wrote:
>> >       (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]