4 ms·
I experience a kind of jolt when I read lispy syntax mixed with constructs like [1, 2, 3]. It shouldn't be a big step to make a syntax for #(1 2 3) or (make-ar
by Xurinos 14y ago
I experience a kind of jolt when I read lispy syntax mixed with constructs like [1, 2, 3]. It shouldn't be a big step to make a syntax for #(1 2 3) or (make-array 1 2 3) instead. Get rid of that infix comma syntax! Then there is the record syntax... {foo: 3, bar: 4}... Infix commas and colons! How about (make-object foo 3 bar 4) or #O(foo 3 bar 4)? Or support reader macros so that you can override []s and {}s to do something a little prettier.
- piranha 14y agoWhy not [1 2 3] and {foo 3 bar 4}? Clojure gets it right. :)
- ynniv 14y agoTwo of the best parts of clojure (over other lisps).
- Xurinos 14y agoFor Common Lisp to support converting [1 2 3] to a vector: ; [] to #() (defun bracket-reader (stream char) (declare (ignore char)) `(vector ,@(read-delimited-list #\] stream t))) (set-macro-character #\[ #'bracket-reader) (set-syntax-from-char #\] #\)) And for your in-place hash: ; {} to hash (defun set-hash-values (hash pairs) (when pairs (setf (gethash (car pairs) hash) (cadr pairs)) (set-hash-values hash (cddr pairs)))) (defun in-place-hash (stream char) (declare (ignore char)) `(let ((hash (make-hash-table))) (set-hash-values hash ',(read-delimited-list #\} stream t)) hash)) (set-macro-character #\{ #'in-place-hash) (set-syntax-from-char #\} #\)) I just sketched these together. I am a CL noob. No doubt there are more concise approaches.
- postfuturist 14y agoAccording to the docs, (array 1 2 3) and (object "foo" 3 "bar" 4) works, too.
- Xurinos 14y agoWhat I get for not penetrating further than the examples. Yay!
- Kjeldahl 14y agoThat's great, but unless someone proves me wrong, it lacks the "list"-style flexibility to do things like "create an object from my list": (object (array "foo" 3 "bar" 4)). Javascript's Array apply method could probably be used to do similar stuff, but that doesn't feel very lispy. FWIW Coffeescript lacks this kind of "object comprehension" as well (which Livescript has BTW).