[elephant-devel] function calls as keyforms for btree-indexes
Sean Ross
rosssd at gmail.com
Thu Jan 10 15:37:12 UTC 2008
Hi all,
I would like to propose the following adjustment to the way that
key-forms for btree indexes are
converted into functions. Currently this is done by looking up the
fdefinition of the symbol provided
or calling compile nil on the form. I would like to amend this to
also allow function forms
eg. '(create-indexer "foo")
Keyform lookup would then work as follows.
a) (and (symbolp key) (fboundp key)) => (fdefintiion key)
b) (and (consp key) (eql (first key) 'lambda)) => (compile nil key)
c) (consp key) => (apply (first key) (rest key))
d) error 'invalid-keyform
and is used something like the following.
(defun create-indexer (tag)
(lambda (idx k v)
(declare (ignore idx k))
(values (find tag (tags-of v))
(tags-of v))))
and indexes using this can be created by using (list 'create-indexer
name) as the key-form.
While the functionality of this can be accomplished using (compile nil
...) it seems a
bit lispier to invoke a function which subsequently returns a function
(and also offers
a performance advantage).
I've attached a patch which implements this on the shared-initalize
:after method for btree-index.
cheers,
sean.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: funcalls.darcs
Type: application/octet-stream
Size: 2590 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/elephant-devel/attachments/20080110/e3973acc/attachment.obj>
More information about the elephant-devel
mailing list