Hi Joachim, On 23/10/2012, at 23:57, Joachim Schimpf <jschimpf_at_...311...> wrote: > On 24/10/2012 00:16, Paulo Moura wrote: >> Hi, >> >> I'm running an experiment where I create a module at runtime (with create_module/3), assert >> clauses into it, but cannot call the asserted predicates (using :/2). Inspecting the module, it >> seams that the visibility for asserted predicates is local. Am I missing something obvious? > > :/2 can only call exported predicates, so that's consistent. > > Use either call(...)_at_m or export the predicate: > > ?- create_module(m). > Yes (0.00s cpu) > > ?- assert(foo(99)) _at_ m. > Yes (0.00s cpu) > > ?- call(foo(X)) _at_ m. > X = 99 > Yes (0.00s cpu) > > ?- m : foo(X). > calling an undefined procedure m : foo(X) in module eclipse > Abort > > ?- (export foo / 1) _at_ m. > Yes (0.00s cpu) > > ?- m : foo(X). > X = 99 > Yes (0.00s cpu) I can reproduce the results above but: Version 6.1development #125 (x86_64_macosx), Tue Oct 9 17:16 2012 ... [eclipse 28]: create_module(n, [], []). Yes (0.00s cpu) [eclipse 29]: assert(bar(99)) _at_ n. Yes (0.00s cpu) [eclipse 30]: call(bar(X)) _at_ n. calling an undefined procedure true in module n Abort From the manual: create_module(Module) :- create_module(Module, [], eclipse_language). Thus, it seems my mistake was to omit the "eclipse_language" in the imports argument. Thanks for your help. Cheers, Paulo ----------------------------------------------------------------- Paulo Moura Logtalk developer Email: <mailto:pmoura_at_...342...> Web: <http://logtalk.org/> -----------------------------------------------------------------Received on Tue Oct 23 2012 - 23:06:23 CEST
This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:20 CEST