Term expansion is unexpectedly not confined to its module
For instance, with m.pl comprising:
:- module(m, []). term_expansion(a, b) :- write(hello).
and p.pl comprising:
:- use_module(m). a.
I get:
$ scryer-prolog p.pl hello
The term expansion defined in m.pl is expected to be confined to that module, and should not affect the fact a. which is defined in p.pl.
This seems problematic but not entirely unexpected.
In both SWI and SICStus, term_expansion is a hook predicate in the user module, blissfully unaware of the module you're declaring it in.
The weird parts to me (and unlike in SICStus) are:
(1) it is implicitly asserted to the user module, instead of needing to be explicitly qualified (e.g. user:term_expansion(a,b) :- write(hello)).
(2) it is implicitly multifile, instead of needing to be declared such.
I don't know if it would uncomfortably different from other Prologs, but it seems more uniform to have such expansion rules registered with a directive (similar to how you hook into initialization with an :- initialization(G) declaration), NOT by defining a "magic" functor.