[elephant-devel] function calls as keyforms for btree-indexes
Robert L. Read
read at robertlread.net
Fri Jan 11 15:32:53 UTC 2008
Thank you Sean.
I don't feel I have enough experience to really comment on this idea, so
I will assume that it is a good one.
I appreciate you providing this patch. However, it would be even better
if this patch were accompanied with tests, or modifications to the
existing test suite, which exercise, demonstrate, and test this feature.
Especially since this is an extension of the API, it makes sense that it
should be tested. If I were to accept the patch without tests, it would
be adding an untested feature, and there would be the danger that in the
future it might be removed, for example, since doing so would break none
of the tests.
So, do you think it might be possible for you to write some tests within
our existing framework to cover this functionality?
On Thu, 2008-01-10 at 15:37 +0000, Sean Ross wrote:
> 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.
> _______________________________________________
> elephant-devel site list
> elephant-devel at common-lisp.net
> http://common-lisp.net/mailman/listinfo/elephant-devel
More information about the elephant-devel
mailing list