| It seems like there's a very common pattern in arc (and lisp in general?) in which you wrap a piece of code you want to execute in a series of forms in the pattern (name (...args...) . body). For instance, here's some code from the SVG thread: (defop circles req
(svgpage
(svg (svg width 500 height 500)
(repeat 20
(svg (circle cx (rand-range 100 400)
cy (rand-range 100 400)
r (rand-range 10 70)
fill (rand-hex-color)
opacity (num (/ (rand-range 4 8) 10))))))))
It should be possible to linearize these and reduce the number of parentheses at the end (and also the amount of syntactic nesting, although not logical nesting). This might work: (defop circles req
(block
(svgpage)
(svg (width 500 height 500))
(repeat 20)
(svg)
(circle cx (rand-range 100 400)
cy (rand-range 100 400)
r (rand-range 10 70)
fill (rand-hex-color)
opacity (num (/ (rand-range 4 8) 10)))))
Block is a form that takes a series of lists, and combines them so that the end of each list gets a sublist which is the rest of the block (also combined with block), and the last list is unmodified.I would appreciate any comments on the idea. The syntax isn't final, but I think it's pretty clear what I intend. (And if you have an idea for how to do it better, by all means, please tell me : ] ) |