Name: Anonymous 2012-12-16 4:23
I was thinking about adding some syntax to make quoting/unquoting easier in my LISP dialect.
A form that uses square brackets, such as
And a form that uses curly brackets would auto
Do you think this would be useful for writing more compact and aesthetically pleasing code? Is this a good approach? Have any LISPs done something like this before?
I know some distant LISP derivatives, such as Clojure, use square brackets and curly braces as syntactic sugar for vector and map/set data structures with auto-unquoting, but I always found that such an approach tended to cause confusion between how the compiler interprets syntactic forms for data structures and how they're actually implemented semantically, in addition to creating syntactic differences between how quoting and unquoting behaves between lists and vectors/maps/sets.
If I really need to construct a vector or other data structure from a sequence of values in code, rather than loading it from a file or generating it, I'd rather just write
What do you think?
A form that uses square brackets, such as
[a b c] would be equivalent to `(,a ,b ,c).And a form that uses curly brackets would auto
unquote atoms and auto unquote-splice lists. So {a [b c] d} would be equivalent to `(,a ,@'(,b ,c) ,c).Do you think this would be useful for writing more compact and aesthetically pleasing code? Is this a good approach? Have any LISPs done something like this before?
I know some distant LISP derivatives, such as Clojure, use square brackets and curly braces as syntactic sugar for vector and map/set data structures with auto-unquoting, but I always found that such an approach tended to cause confusion between how the compiler interprets syntactic forms for data structures and how they're actually implemented semantically, in addition to creating syntactic differences between how quoting and unquoting behaves between lists and vectors/maps/sets.
If I really need to construct a vector or other data structure from a sequence of values in code, rather than loading it from a file or generating it, I'd rather just write
(list->vector `(1 2 3 a)) or (list->vector [1 2 3 'a]) or simply (vector 1 2 3 'a).What do you think?