2 ms·
I find that alternative syntaxes like this for S-expressions tend to get really awkward when confronted with real-world Lisp code. For example, the following co
by chc 14y ago
I find that alternative syntaxes like this for S-expressions tend to get really awkward when confronted with real-world Lisp code. For example, the following code sample†:
(define (pointless-function a z)
(let* ((numbers (map (lambda (n) (* n 2)) (range a z)))
(multiple-of-three? (lambda (n) (= 0 (mod n 3))))
(multiples-of-three (filter multiple-of-three? numbers)))
(printf "Your numbers are: ~s~%" multiples-of-three)))
AFAIK, this code only gets noisier when you introduce a paren-free syntax, as you need to introduce hacks to get around the simultaneous necessity and lack of parentheses.
† OK, I'll grant you, this function is not at all realistic. But I think the structure of the code is pretty lifelike. I didn't have any Lisp code at hand to use as an example, so I just banged out something that used let and lambda to illustrate that the structure of S-expressions can be pretty intricate.
- qu4z-2 14y agoMy ideal s-expression syntax would allow you to replace some brackets with whitespace. For instance, your function would become: define (pointless-function a z) let* numbers (map (lambda (n) (* n 2)) (range a z)) multiple-of-three? (lambda (n) (= 0 (mod n 3))) multiples-of-three (filter multiple-of-three? numbers) printf "Your numbers are: ~s~%" multiples-of-three Obviously there are some down-sides, but the main idea is that the mapping should have no knowledge of the language details, and be a pure s-expression transform. I really should explore the idea more. I have no idea whether the above example can even be uniquely parsed.