Term_expansion across several modules

I am using term_expansion to create a small Domain Specific Language (DSL) – essentially writing something like this:

term_expansion(keyword(X), dsl(keyword(X)).

I then use a failure driven loop to process all keywords, as so:

process :-


All this is written in a mail file.

I am now wondering if i can include, somehow, keywords included in modules as well.

Right now, it seems i would need to redo all term_expansion declarations in the module, and the failure loop in the main file wouldn’t see the generated dsl/1 terms inside of the module.

Is there a way to handle this.



1 Like

I’ll do this differently …

I will just use several files – not modules – and include (consult) them … it will all be in the global (user?) module.


Would make dsl/1 a multifile predicate work in you case? That way all clauses for the predicate would be in the same module. Something like:

:- module(keywords, [dsl/1]).

:- multifile(dsl/1).


term_expansion(keyword(X), keywords:dsl(keyword(X)).
1 Like