nuntius wrote:Comments:
- Read macros are best reserved for syntax which cannot be parsed by the normal lisp reader. Or at least very frequently used shorthand.
I agree that read macros should be used sparsely, but
everything can be parsed by the normal lisp reader. I know that defining new higher order functions is not so frequent as using existing ones, but it is a good way to express a concept often enough.
- Post an example use of your read macro; I suspect it only saves a few characters. While FUNCTION only has one more character, it often appears more frequently than FUNCALL. Also FUNCTION always takes a single argument; so the #' macro saves a set of parens as well. Finally, both QUOTE and FUNCTION are special operators, whereas FUNCALL is a mere function.
Example:
Code: Select all
(#^fun arg) ; expands to (funcall fun arg)
I agree that the savings with the #' reader macro are bigger. However, what lies underneath the macro is not my concern, my goal is to express the symmetry of "exceptionally executing something from the value namespace" and "exceptionally referring to something from the function namespace as a value".
- Wouldn't a symbol macro named FC be equivalently useful?
Yes, you could even call it "^". However, my thought is symmetry:
When calling higher order functions (which is much more common), there is already the reader macro #':
Code: Select all
(mapcar #'zerop list) ; expands to (mapcar (function 'zerop) list)
The concept I see embodied in this reader macro is "referring to things from the 'other' namespace". Therefore, I think that a visually similar thing should be existent for the (in a sense) reverse case:
Code: Select all
(foo #'bar baz) ; the function thing of foo is applied to the function thing of bar and the value thing of baz
(#^foo bar baz) ; the value thing of foo is applied to the value thing of bar and the value thing of baz
- I never thought separate function and value namespaces had anything to do with more or less typing.
I encountered the argument that when defining a new higher order function, you often have to type out the FUNCALL in a Lisp-n, while this is not needed in a Lisp-1:
Code: Select all
(defun hof (fun arg)
(funcall fun arg))
versus
- Since # is "the" dispatch character and there aren't many remaining subchars, read-macro collisions are common. Hence they shouldn't be used lightly in libraries; but application code can use them liberally.
Actually, there are quite a few undefined subchars, they just aren't explicitly reserved for the user:
http://www.lispworks.com/documentation/ ... /02_dh.htm. I guess that the rest is meant to be used by implementations.