Replies: 2 comments 3 replies
-
I think a directive is just any clause with an empty head, what they do (apart from the ISO ones) is implementation defined. One way to "make them do something" is turning them into some other thing that actually does what you want, and the way to do that (for clauses) in Scryer Prolog seems to be term expansion. I guess we could add some specialized mechanism to define directives, but I don't think it's worth the added complexity and technical debt. Performance could be improved a lot by just improving indexing (and yes, there is a lot of room to improve there; we don't even have JIT indexing yet), and that would also improve everything else. |
Beta Was this translation helpful? Give feedback.
-
Another example of a directive implemented as a term expansion: Lines 36 to 41 in 9785a04 |
Beta Was this translation helpful? Give feedback.
-
The only example I could readily fine of what makes something "a directive" in Scryer Prolog is the tabling directive:
https://github.com/mthom/scryer-prolog/blob/master/src/lib/tabling/wrapper.pl#L118-L125
I note that it uses
term_expansion/2
-- my understanding is thatterm_expansion/2
affects ALL terms. That seems like a bit of a heavy price to pay for a user defined directive, doesn't it?Is this the only way?
Beta Was this translation helpful? Give feedback.
All reactions