3 ms·
Note I said "or looks like one". If you squint a bit, macros and built-ins are similar in structure to functions (they're all s expressions). I agree with muc
by axle_512 8y ago
Note I said "or looks like one".
If you squint a bit, macros and built-ins are similar in structure to functions (they're all s expressions).
I agree with much of what you said, but I still maintain that lisp syntax is still relatively trivial compared to most languages.
I also don't think exposing newcomers to macros on a language that is homoiconic is terribly useful until they're already comfortable with the basic s-expression syntax.
- lispm 8y ago> If you squint a bit, macros and built-ins are similar in structure to functions Because they have a parenthesis in front and back and the operator as first element. Macros then implement complex code structures between those: (foo a b) and then (let ((a 10) b) (declare (type (integer 0 100) b) (type number a)) (declare (optimize (speed 3)) (declare (special a b) (dynamic-extent a)) (prog () start (setf b (+ a 10)) (go end) end) (the integer (+ a a b))) Now remove the parentheses. Looks like a program in a typical language. Macro forms have lots of internal structure. For an extreme example check the syntax definition of the LOOP macro. Two pages of EBNF syntax declaration. That there are an opening parentheses and a closing one does not suddenly remove the syntax: loop for i from 1 below 10 by 2 and for j from 2 upto 50 by 3 when foo(i, j) collect i into is and j into js and i * j into ps when bar(i) > baz (j) return list(is, js, ps) or the Lisp version: (loop for i from 1 below 10 by 2 and for j from 2 upto 50 by 3 when (foo i j) collect i into is and j into js and (* i j) into ps when (> (bar i) (> baz j)) return (list is js ps)) Does it LOOK like it has less syntax? Not really. > lisp syntax is still relatively trivial compared to most languages Not really. Check out the concept of a code walker in Lisp. That's a tool which understands Lisp syntax and can walk over Lisp code and do transformations. Here is one: https://gitlab.common-lisp.net/cl-walker/cl-walker/tree/master/src https://gitlab.common-lisp.net/cl-walker/cl-walker/tree/mast... Mildly complex... complexity comes in, because Lisp has built-in syntax transformations via macros.
- axle_512 8y agoFair enough, I see your point. Though stylistically my personal preference is for the macro to remain as simple as possible with limited syntax introduced.