Re: inlining and (compile
- From: Barry Margolin <barmar@xxxxxxxxxxxx>
- Date: Thu, 24 May 2007 19:41:14 -0400
In article <1180031251.581633.291450@xxxxxxxxxxxxxxxxxxxxxxxxxxx>,
Joe Marshall <eval.apply@xxxxxxxxx> wrote:
On May 24, 10:36 am, Sacha <n...@xxxxxxxxxxxx> wrote:
Hello all,
I'm in a quest to make functional data structures, with referencial
transparency. In the process i had to define a record structure, which
is based on arrays.
The whole thing is easy with macros, but i'd like to have a functional
interface underlying those macros. (as record types need to be redefined
dynamically when one of their "superclass" is redefined)
Defining accessors from the functional interface is trivial using the
compile function. But i would like those accessors to be inlined as well.
so i did something like this :
(defun make-accessor (class-name slot-name slot-index)
(eval `(declaim (inline ,(slot-name class-name slot-name))))
Use PROCLAIM instead of EVAL of DECLAIM:
(proclaim `(inline ,(slot-name class-name slot-name)))
(compile (slot-name class-name slot-name)
`(lambda (instance)
(aref instance ,slot-index))))
That's weird. Why not a macro?
I think because he's creating these things at runtime. BTW, why does
your supposed macro definition start with DEFUN? :)
(defun make-accessor (class-name slot-name slot-index)
`(progn
(declaim (inline ,(slot-name class-name slot-name)))
(defun ,(slot-name class-name slot-name) (instance)
(aref instance ,slot-index))))
--
Barry Margolin, barmar@xxxxxxxxxxxx
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
.
- Follow-Ups:
- Re: inlining and (compile
- From: Sacha
- Re: inlining and (compile
- References:
- inlining and (compile
- From: Sacha
- Re: inlining and (compile
- From: Joe Marshall
- inlining and (compile
- Prev by Date: Re: My First Lisp...
- Next by Date: Re: Dumbing down?
- Previous by thread: Re: inlining and (compile
- Next by thread: Re: inlining and (compile
- Index(es):