This is the mail archive of the guile@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: catch/throw functionality


Vollmer Marius  <mvo@zagadka.ping.de> writes:

> Hmm, I think this is quite clever, actually.  I think it is supposed
> for efficient implementation of a "return"-like feature.  Like
> 
>     (defmacro body forms
>       `(let ((body-proc (lambda (return) ,@forms)))
> 	 (catch #f 
> 		(lambda (return-point)
> 		  (body-proc (lambda (val) (throw return-point val))))
> 		(lambda (key val)
> 		  val))))
> 
>     (pk 'return (body
> 		 (pk 1)
> 		 (return 2)
> 		 (pk 3)))
> 
> But then again, it is probably unlikely that there are a large number
> of catch/throw activations between the return-point-establishing-catch
> and the invocation of return.

Yes, this is unlikely.

> So bypassing the search for a symbolic key might not be a
> significant improvement.  But it is at least elegant, IMO.

My view is that the degree of elegance is decreased by the increased
complexity of the catch/throw mechanism.  And I think the usage
pattern you demonstrate isn't common enough to motivate this increased
complexity.

Are you sure that you don't want me to remove this mechanism?

/mdj