Hi Joachim! What does the "@Module" statement do? -----Original Message----- From: Joachim Schimpf [mailto:jschimpf_at_coninfer.com] Sent: Thursday, May 29, 2014 4:20 AM To: eclipse-clp-users_at_lists.sourceforge.net Subject: Re: [eclipse-clp-users] Checking for existing clauses without dynamic definition? 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)@Module, abolish(F/N)@Module, compile_term(Clauses)@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) -- Joachim ------------------------------------------------------------------------------ Time is money. Stop wasting it! Get your web API in 5 minutes. www.restlet.com/download http://p.sf.net/sfu/restlet _______________________________________________ ECLiPSe-CLP-Users mailing list ECLiPSe-CLP-Users_at_lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/eclipse-clp-usersReceived on Thu May 29 2014 - 23:29:26 CEST
This archive was generated by hypermail 2.2.0 : Sat May 31 2014 - 06:13:31 CEST