A cute reader hack
- From: Ron Garret <rNOSPAMon@xxxxxxxxxxx>
- Date: Sun, 30 Apr 2006 13:44:31 -0700
For those who like to program in a functional style without having to
type FUNCALL all the time:
(defun \_-reader (stream char)
(declare (ignore char))
`(lambda (&rest #1=#.(gensym "ARGS")) (apply ,(read stream) #1#)))
(set-macro-character #\_ '\_-reader t)
Now you can call the local version of a function simply by preceding its
name with an underscore. (The cost is that you lose the ability to have
variables and functions whose names begin with underscore. If you don't
like that you can choose a different character, or use a dispatching
macro character.)
e.g.:
(defun foo (list)
(list 1 (_list 2))) ; Instead of (list 1 (funcall list 2))
(foo #'vector) --> (1 #(2))
rg
.
- Follow-Ups:
- Re: A cute reader hack
- From: Kalle Olavi Niemitalo
- Re: A cute reader hack
- From: Kaz Kylheku
- Re: A cute reader hack
- From: Andras Simon
- Re: A cute reader hack
- From: Pascal Costanza
- Re: A cute reader hack
- Prev by Date: Re: time to bring back the Lisp machines?
- Next by Date: Re: Which lisp for a (lisp) novice?
- Previous by thread: Re: time to bring back the Lisp machines?
- Next by thread: Re: A cute reader hack
- Index(es):
Relevant Pages
|