Logtalk, . :
:- object(my_code).
:- public([a_rule/1, ...]).
:- private([fact/1, another_fact/1, ...]).
:- dynamic([fact/1, another_fact/1, ...]).
a_rule(Term) :-
::fact(...), ...
...
:- end_object.
, ( ) my_code:
?- create_object(my_store, [extends(my_code)], [], []).
, :
?- my_store::a_rule(Term).
create_object/4 ( , ):
?- create_object(my_store, [extends(my_code)], [include('my_store.pl'))], []).
, :
?- my_store::assertz(fact(...)).
, my_code. :
:- public(dump/0).
dump :-
self(Self),
atom_concat(Self, '.pl', File),
tell(File),
dump_dynamic_predicates,
told.
dump_dynamic_predicates :-
current_predicate(Functor/Arity),
functor(Template, Functor, Arity),
predicate_property(Template, (dynamic)),
::Template,
write_canonical(Template), write('.\n'),
fail.
dump_dynamic_predicates.
, :
?- my_store::dump.
Note that with this solution it is trivial to have any number of data stores at the same time. If the data warehouse requires a specialized version of the code, you can simply expand the code object and then create a specialized data warehouse as an extension of this specialized object.