[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: loop macro



	From: Daniel L. Weinreb <DLW@SCRC-QUABBIN.ARPA>

 	   Date: Wed, 5 Feb 86 12:01 EST
 	   From: Guy Steele <gls@THINK-AQUINAS.ARPA>

	    Okay, now here is a different perspective on the LOOP problem.  I
will play
 	   devil's advocate here and claim that the main purpose of LOOP is to
 	   duplicate the functionality of the sequence functions.  

	(1) Your message later goes on to say "This isn't operating on
	sequences, so I will render this as a DO loop."  This in no way
	supports the original thesis!  Many simple examples of LOOP don't
	operate on sequences:

 	 (loop for x from 3 to 6
  	      do (print x))

I think the best answer for this particular kind of example is the
following from Larry Masinter:

	We could enhance the sequence functions using Common Loops if we
	define default implementations for them which use only the methods
	that all ordered collections must follow, and then include new classes
	for Interval. This is the approach used successfully in Smalltalk for
	dealing with iteration.

In particular, how about:

(map #'print (interval 3 6))


Admittedly, many of GLS's other DO loops examples may be difficult or
inappropriate to rephrase this way.