| This is a new idea I just thought of, and I would like comments from other members of the community. The goal is to address code like this: (with (foo 5 bar 6)
(synchronized-zone (something)
(extra-coolness
(lambda (whatever) ... ))))
It seems like nested forms can sometimes become a lot to keep track of, and cause the code to be indented a lot. Furthermore, a lot of the time, a function will have the structure of a bunch of outer binding forms, or forms that otherwise modify how code is executed, and then a few statements on the inside, like the above example.To try to make this more manageable, I thought of making ,# a special syntax character. When ,# appears in a form, then the reader would look at all of the statements following that form in whatever encloses it and splice them all in as a list at the point of the ,#. So the above example would become (with (foo 5 bar 6) ,#)
(synchronized-zone (something) ,#)
(extra-coolness ,#)
(lambda (whatever) ...)
This would let you easily use forms of the pattern (modify (in this way) code ...)
By writing it as (modify (in this way) ,#)
code ...
If you don't like the fact that it grabs the entire rest of the block, you can work around it with just one level of nesting: (do
(with (foo 12 bar 'u) ,#)
(synchronize (backend) ,#)
(get-data))
(do
(with (foo 12 bar 'z) ,#)
(synchronize (frontend) ,#)
(write-data))
If you did this at the beginning of a file at the top level, you could effectively change the programming language you were using for the rest of the file, which I think has interesting uses for DSLs.I chose comma by analogy with the quasiquote syntax, and put a # after it because I don't think it's being used for anything else right now. |