> Hi Joe, interested to know what the advantage is,
> since the current code looks prettier, cleaner and more obvious than  
> your syntax.
>
> especially the seperation of quotations, and the different character  
> (curly brace) to encompass them all with 3&&
>
> you add two characters to figure out, and break the encapsulation of  
> the quotation.
> maybe I miss-understand your purpose here

It's a matter of taste, perhaps, but to me, adding two layers of depth  
({ [ ] }) for basic things like a short-circuit sequence or repeated  
use of a value always felt a bit too much. The quotations in a cleave,  
spread, &&, or other sequence macro are interrelated enough that I  
feel a lighter-weight syntax is justified. The wins of my proposed  
syntax aren't very obvious with the medium-sized example I gave, but  
if you look at some very small or very large examples, I think it  
becomes more clear. On the small side, a simple cleave with several  
short quotations looks pretty heavy with all those brackets:

20 { [ 1+ ] [ 1- ] [ 2^ ] } cleave

Now we have bi and tri, which make that outer array layer unnecessary  
for 2- or 3-branch cleaves, but they add maintenance overhead when you  
add or remove a branch; you either need to change the "bi" or "tri"  
word to match the new number of branches, or wrap the whole works in  
"cleave" when you hit more than three. To me, the shorthand syntax  
makes always using the general "cleave" more tolerable and the bi/tri  
words less necessary:

20 [[ 1+ ;; 1- ;; 2^ ]] cleave
! vs.
20 [ 1+ ] [ 1- ] [ 2^ ] tri

"tri" is still a shorter word than "cleave", but other than that,  
those two lines are even in number of keystrokes spent. The "cleave"  
line is more flexible; you can easily add a fourth branch or remove a  
branch without altering the surrounding structure of the code.

(As an aside, I agree that ";;" doesn't have as much visual weight as  
it should to separate quotations. I considered using "|" or "||", but  
the former is already used in locals and the latter has too strong a  
history as "logical OR". Maybe "][" would be better?)

On the other end, if you have an epic cleave with branches spanning  
multiple lines, the standard syntax and indentation conventions  
require two levels of indentation and a blank line between each  
quotation:

gadget {
     [
         GL_PROJECTION glMatrixMode
         glLoadIdentity
         set-projection-matrix
     ] [
         GL_MODELVIEW glMatrixMode
         glLoadIdentity
         set-modelview-matrix
     ] [
         ...
     ] [
         ...
     ]
} cleave

(Not necessarily code you'd actually write, but just an illustrative  
example.) The shorthand syntax sheds a bunch of weight, I think:

gadget
[[ GL_PROJECTION glMatrixMode
    glLoadIdentity
    set-projection-matrix
;; GL_MODELVIEW glMatrixMode
    glLoadIdentity
    set-modelview-matrix
;; ...
;; ...
]] cleave

Again, it may just be a matter of taste.

-Joe

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to