I'm looking for some feedback... should sweet-expressions be adjusted to handle 
really long Common Lisp loop statements?

Sweet-expressions work just great with relatively short Common Lisp loop 
statements.  But here's an example from hunchentoot version 1.2.18 file 
request.lisp line 176+:

(loop with buffer = (make-array +buffer-length+ :element-type 'octet)
      with content = (make-array 0 :element-type 'octet :adjustable t)
      for index = 0 then (+ index pos)
      for pos = (read-sequence buffer content-stream)
      do (adjust-array content (+ index pos))
         (replace content buffer :start1 index :end2 pos)
      while (= pos +buffer-length+)
      finally (return content))

So... what should be done with really LONG loop expressions like this?
The best approach I've found currently is to just use parens to disable indent 
processing:
(loop with buffer = make-array(+buffer-length+ :element-type 'octet)
      with content = make-array(0 :element-type 'octet :adjustable t)
      for index = 0 then {index + pos}
      for pos = read-sequence(buffer content-stream)
      do adjust-array(content {index + pos})
         replace(content buffer :start1 index :end2 pos)
      while {pos = +buffer-length+}
      finally return(content))

That actually isn't bad; you still have neoteric-expressions.
That could be annoying, though, if the "do" body is long.

Using "\\" between parameters works find if there are pairs
(e.g., keywords paired with data), but not well with:
      with \\ content \\ = \\ make-array(0 :element-type 'octet :adjustable t)

The one alternative approach I can think of is "\\"-at-the-end, a dropped 
proposal
to allow line splicing if "\\" is at the end of a line with at least 1 
neoteric-expression
is on its left.  Then you can do:
loop with buffer = make-array(+buffer-length+ :element-type 'octet) \\
      with content = make-array(0 :element-type 'octet :adjustable t) \\
      for index = 0 then {index + pos}
...


So... is this a problem that needs solving?  Is it adequately handled already?
If not, are there suggestions for solving it?

Comments welcome.  I'd like to finish SRFI-110, but now's the time to know
if there's a weakness that needs addressing.

--- David A. Wheeler

------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Readable-discuss mailing list
Readable-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/readable-discuss

Reply via email to