info-gnuprologjava
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Info-gnuprologjava] Question on loading Prolog files


From: Sergio Castro
Subject: Re: [Info-gnuprologjava] Question on loading Prolog files
Date: Tue, 21 May 2013 01:53:33 -0700 (PDT)

Thanks for answering Daniel.
I got that I can call "environment.ensureLoaded" safely after the interpreted has been initialized.
The important thing to know for me is what happens if the ensure_loaded/1 predicate is present in one of the new clauses loaded from a file ?
I mean, if this predicate is executed as part of the resolution of a query, the initialization code in the files it loads is NOT going to be executed, right ?

Thanks for your help,

Sergio


De : Daniel Thomas <address@hidden>
À : Sergio Castro <address@hidden>
Cc : "address@hidden" <address@hidden>
Envoyé le : Mardi 21 mai 2013 10h35
Objet : Re: [Info-gnuprologjava] Question on loading Prolog files

Hello Sergio,

The ISO predicate "ensure_loaded/1" does work. I am pretty sure that
doing "env.runInitialization(...)" again will only execute new
initialization goals as I recall there as being a list which gets
processed and emptied.

I hope that helps,

Daniel

On Fri, 2013-05-17 at 10:43 -0700, Sergio Castro wrote:
> I was looking for a Prolog interpreter embedded in Java and this
> project took my interest.
>
>
>
> I am reading the setup instructions in the user manual
> (http://www.gnu.org/software/gnuprologjava/manual/Constructing-Terms.html#Constructing-Terms) and there is something that is not entirely clear to me. Quoting relevant sentences from the manual:
>
>
>
> ---
>
> ..."load any prolog files you want to which define additional
> predicates etc using environment.ensureLoaded(AtomTerm.get(``URL of
> file'')) for each file. " ...
> "you will need to create at least one gnu.prolog.vm.Interpreter which
> is used to execute goals. You do this using
> environment.createInterpreter(). "
>
> "Having created it you need to use it to run the initialization of any
> files you have loaded by using env.runInitialization(interpreter);.
> This ensures the goals contained in any “:- initialization(goal).” or
> “:- goal.”s in the files you have loaded are run."
> ---
>
>
>
> Does it mean that the only mechanism for loading files is with
> "environment.ensureLoaded" ? So the ISO predicate "ensure_loaded/1"
> does not work ?
> I am wondering if there is a way to load additional files after the
> Interpreter has been created and initialized with
> "env.runInitialization(...)"?
>
>
> I guess that in case "environment.ensureLoaded(...)" needs to be
> called again AFTER the instantiation and initialization of the
> interpreter then
> "env.runInitialization(...)" should also be called again in order to
> load any “:- initialization(goal).” or “:- goal.”s in the new loaded
> file ???.
>
> If this is correct, does it mean that all the initialization
> directives that were executed in the first call to
> "env.runInitialization(...)" will be executed again ?
>
>
>
> Thanks for any help on this regard,
>
>
> cheers,
>
>
> Sergio
>
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]