|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Lisp accessors for PL-ITERATOR values.Just to close out this discussion, since there was a wrinkle I had
forgotten about: PowerLoom's lisp translation comes in two versions, one which uses CLOS objects to implement the Stella/PowerLoom objects and one which uses structs (defstruct) instead. The default release uses structs for speed. But the accessors for slots look different in the CLOS and the STRUCT version. In the CLOS version, values from Pl-iterator are accessed using the generic function "%value", which works for all iterators and is always in the STELLA package. In the Struct version, values from Pl-iterator are accessed using the function "%pl-iterator.value" in the PLI package, which works only on pl-iterators. Other iterators have their own, specially qualified names that are used to get the values, generally in the STELLA package. So that means that if you write lisp code to manipulate pl-iterators, you need to be aware of this distinction. For the more common Struct case, you could iterator through all concepts by doing something like: (let ((iter (pli:s-retrieve "all (concept ?x)" "PL-USER" null))) (loop while (stella::next? iter) do (print (pli::%pl-iterator.value iter)))) _______________________________________________ powerloom-forum mailing list powerloom-forum@... http://mailman.isi.edu/mailman/listinfo/powerloom-forum |
|
|
Re: Lisp accessors for PL-ITERATOR values.Thomas Russ wrote:
> Just to close out this discussion, since there was a wrinkle I had > forgotten about: > > PowerLoom's lisp translation comes in two versions, one which uses > CLOS objects to implement the Stella/PowerLoom objects and one which > uses structs (defstruct) instead. The default release uses structs > for speed. But the accessors for slots look different in the CLOS > and the STRUCT version. > > In the CLOS version, values from Pl-iterator are accessed using the > generic function "%value", which works for all iterators and is > always in the STELLA package. > > In the Struct version, values from Pl-iterator are accessed using the > function "%pl-iterator.value" in the PLI package, which works only on > pl-iterators. Other iterators have their own, specially qualified > names that are used to get the values, generally in the STELLA package. > > So that means that if you write lisp code to manipulate pl-iterators, > you need to be aware of this distinction. For the more common Struct > case, you could iterator through all concepts by doing something like: > > > (let ((iter (pli:s-retrieve "all (concept ?x)" "PL-USER" null))) > (loop while (stella::next? iter) > do (print (pli::%pl-iterator.value iter)))) Is there any reason why compile-time conditionalization of the #+ sort couldn't be used to hide this from the programmer? I.e., something like #-stella-clos (defun %value (x) (pli::%pl-iterator.value iter))) or, for that matter can't you provide a clos accessor to the iterators, something like this: (defmethod %value ((pli::%pl-iterator x)) (pli::%pl-iterator.value))) I suppose the latter is less desirable, since the method dispatch might be costly... best, r -- Robert P. Goldman Senior Scientist Smart Information Flow Technologies (d/b/a SIFT, LLC) 211 N. First St., Suite 300 Minneapolis, MN 55401 Voice: (612) 384-3454 Email: rpgoldman@... _______________________________________________ powerloom-forum mailing list powerloom-forum@... http://mailman.isi.edu/mailman/listinfo/powerloom-forum |
| Free Forum Powered by Nabble | Forum Help |