Alan Manuel Gloria:
> As an aside, one thing we *still* don't support very well is CL's
> loop.  You're pretty much constrained to use parens for that to get
> any readability.

Miracle-working takes extra work :-).  CL's loop is remarkably ugly in any 
form.  You're probably better off defining a sane macro that maps to the 
underlying stuff than using it directly.  Still, it might be instructive to 
look at it.

Here's an example from Steele's "Common Lisp: The Language" 2nd ed, page 710:
(loop for i from 1 to (compute-top-value)
 while (not (unacceptable i))
  collect (square i)
  do (format t "Working on ~D now" i)
  when (evenp i)
    do (format t "~D is a non-odd number" i)
  finally (format t "About to exit!"))

You could just use (...) and handle it with modern-expressions.  That's 
probably what I'd do, since CL loops represent a particularly nasty case for 
indentation processing:

(loop for i from 1 to compute-top-value()
 while not(unacceptable(i))
  collect square(i)
  do format(t "Working on ~D now" i)
  when evenp(i)
    do format(t "~D is a non-odd number" i)
  finally format(t "About to exit!"))

But we could try using indentation processing, using "~" as SPLIT and GROUP.  
Here's my try; it's not beautiful, but it's not too bad considering what we're 
trying to do:

loop for i from 1 to compute-top-value()
. while ~ not unacceptable(i)
. collect ~ square(i)
. do ~ format(t "Working on ~D now" i)
. when ~ evenp(i)
. ~ do ~ format(t "~D is a non-odd number" i)
. finally ~ format(t "About to exit!"))

I wouldn't want to design a notation just for CL loops; people point to that as 
something "we never want to do again".  But if there's a simple general 
technique that solves many issues, then great.

Thoughts?

--- David A. Wheeler

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Readable-discuss mailing list
Readable-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/readable-discuss

Reply via email to