Hi Joachim, On 23/10/2012, at 23:57, Joachim Schimpf <jschimpf_at_coninfer.com> 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(...)@m or export the predicate: > > ?- create_module(m). > Yes (0.00s cpu) > > ?- assert(foo(99)) @ m. > Yes (0.00s cpu) > > ?- call(foo(X)) @ m. > X = 99 > Yes (0.00s cpu) > > ?- m : foo(X). > calling an undefined procedure m : foo(X) in module eclipse > Abort > > ?- (export foo / 1) @ 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)) @ n. Yes (0.00s cpu) [eclipse 30]: call(bar(X)) @ 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_logtalk.org> Web: <http://logtalk.org/> -----------------------------------------------------------------Received on Tue Oct 23 2012 - 23:06:23 CEST
This archive was generated by hypermail 2.2.0 : Wed Oct 24 2012 - 06:13:58 CEST