On 29/05/2014 11:48, Marco Gavanelli wrote: > Dear Gesche, > > Maybe you could use abolish/1 to remove the dynamic predicate and then > use compile_term/1 to re-add the predicate in compiled form. > > Example: > ------------------------------------------------------------------ > [eclipse 1]: assert(p:-q). > > Yes (0.00s cpu) > [eclipse 2]: compile_term(q). > source_processor.eco loaded in 0.00 seconds > ... > ecl_compiler.eco loaded in 0.05 seconds > > Yes (0.05s cpu) > [eclipse 3]: clause(p,X). > > X = q > Yes (0.00s cpu) > [eclipse 4]: abolish(p/0). > > Yes (0.00s cpu) > [eclipse 5]: p. > calling an undefined procedure p in module eclipse > Abort > [eclipse 6]: compile_term(p:-q). > > Yes (0.00s cpu) > [eclipse 7]: clause(p,X). > procedure not dynamic in clause(p, X) in module eclipse > Abort > [eclipse 8]: p. > > Yes (0.00s cpu) > --------------------------------------------------------------------- Correct. Here is a little utility that does everything: :- tool(dynamic_to_static/1, dynamic_to_static_/2). dynamic_to_static_(F/N, Module) :- functor(Head, F, N), findall(Head:-Body, clause(Head, Body), Clauses)_at_Module, abolish(F/N)_at_Module, compile_term(Clauses)_at_Module. ?- assert(p(111)), assert(p(222)). Yes (0.00s cpu) ?- dynamic_to_static(p/1). Yes (0.00s cpu) ?- is_dynamic(p/1). No (0.00s cpu) ?- p(X). X = 111 Yes (0.00s cpu, solution 1, maybe more) X = 222 Yes (0.02s cpu, solution 2) -- JoachimReceived on Thu May 29 2014 - 11:47:20 CEST
This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:21 CEST