Re: fn abstraction?
- From: Kaz Kylheku <kkylheku@xxxxxxxxx>
- Date: 30 May 2007 20:34:01 -0700
On May 30, 8:18 pm, Nate <beta.entit...@xxxxxxxxx> wrote:
so I've been wondering, am I missing something hideously wrong with
this? As in, is there something ugly, etc? because it's clear when you
use it for one use or the other, and I'm wondering why it's not been
done before (probably readability?).
(defmacro fn (&body bd)
(if (consp (first bd))
`(function (lambda ,(first bd) ,@(cdr bd)))
`(defun ,(first bd) ,(second bd) ,@(cddr bd))))
as in
(mapcar #'(lambda (x y) (list x y)) lst1 lst2) =>
(mapcar (fn (x y) (list x y)) lst1 lst2)
So now you can do
(mapcar (fn foo) ...) ;; named
(mapcar (fn (x y) ...) ;; anon
Versus
(mapcar (funtion foo) ...)
(mapcar (lambda (x y) ...) ...)
Doesn't buy anything. The real action is in semantics, and what action
there is in syntax, it is outside of trivial transliterations like
this.
Also consider that function names can be compound forms, giving rise
(fn (setf foo) ...) being misinterpreted into (lambda (setf foo) ...).
.
- References:
- fn abstraction?
- From: Nate
- fn abstraction?
- Prev by Date: Re: code critique
- Next by Date: Re: Continuation based app servers
- Previous by thread: fn abstraction?
- Index(es):