From jan@swi.psy.uva.nl  Fri Feb 18 09:52:50 2000
Received: from gollem.swi.psy.uva.nl (root@gollem [145.18.152.30])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id JAA21765;
	Fri, 18 Feb 2000 09:52:50 +0100 (MET)
Received: from localhost (localhost [[UNIX: localhost]])
	by gollem.swi.psy.uva.nl (8.9.3/8.9.3/SuSE Linux 8.9.3-0.1) id JAA29097;
	Fri, 18 Feb 2000 09:52:53 +0100
From: Jan Wielemaker <jan@swi.psy.uva.nl>
Organization: SWI, University of Amsterdam
To: Lesta@t-online.de (Uwe Lesta)
Subject: Re: How to build a Runtime which loads a *.qlf ?
Date: Fri, 18 Feb 2000 09:40:19 +0100
X-Mailer: KMail [version 1.0.28]
Content-Type: text/plain
References: <38AB3C08.B4848D1D@t-online.de> <00021711315300.17188@gollem> <38AC6866.DCB86058@t-online.de>
In-Reply-To: <38AC6866.DCB86058@t-online.de>
Cc: prolog@gollem.swi.psy.uva.nl
MIME-Version: 1.0
Message-Id: <00021809525300.29060@gollem>
Content-Transfer-Encoding: 8bit

On Thu, 17 Feb 2000, you wrote:
>Jan Wielemaker schrieb:
>
>> First the remark: the runtime system was never meant to load code
>> besides simple rule-bases, configuration, etc. at runtime 
>
>Bad news, Prolog in combination with XPCE seduce to a disign like
>mine.
>
>> My suggestion is *not* to use any of the standard loading primitives
>> to refer to parts of the kernel.  Instead, use the upcomming ISO
>> stuff, where not the name of the file, but the name of the module
>> matters.  I would write:
>> 
>> :- meta_predicate
>>         import_module(:).
>> 
>> import_module(Spec) :-
>>         strip_module(Spec, Into, Module),
>>         (   predicate_property(Head, exported(Module)),
>
>--        (   predicate_property(Head, exported(Module)),
>++        (   Module:predicate_property(Head, exported),
>
>>             Into:import(Module:Head),
>>             fail
>>         ;   true
>>         ).
>

Actually:

	predicate_property(Module:Head, exported(Module)),
	
(is the same, but more elegantly).

>Ufff, the runtime version work with the change above and many others.
>
>Many thanks to you.
>
>What I am missing in the specification of import_module/1 is a kind
>of loading for the specified module if it isn't loaded. But i think 
>this fails by the missing knowledge about the relation between the module-
>and the filename.

You should use the import_module to refer to modules that are part of
the development system (i.e. libraries) and you should make sure they
are loaded into the runtime.  You can (should) use use_module for
files you distribute with your application.

>Do you know what ISO will say to this ?
>What is your advice ?

The proposed module system for ISO is very different from the syntax
point of view.  The execution model is very close.  One difference
though is that the argument to use_module/1 is the name of a module,
rather than the name of a file.  The also split a module into its
signature and body and allow for multiple modules in one file.

One big problem is that they partially use the same predicate names
with different semantics.  Sofar I haven't thought a lot about providing
ISO compliant module system.  I'll first wait for the proposal to
settle.

>> >- use_module is a very nice thing for development but in a runtime
>> >  version of a qlf file it causes the warning
>> >  "directive failed: frage:use_module ..."
>> >  I'll like to have the use_module's in the file to consult and test
>> >  this single file.
>> >
>> >  I'll solved this with
>> >
>> >    (   feature(runtime, true)
>> >    ->  redefine_system_predicate(use_module(_)),
>> >        asserta(use_module(_))
>> >
>
>Is this a good idea ? What is your advice ?

Generally, use your own predicate name and define that in module user
to make a call depending on the runtime flag (now current_prolog_flag/2,
feature/2 is compatibility only).

>> >
>> >import/1: pce_util:chain_list/2 is not declared public (still imported)
>
>How should I interpret this message ?
>It seems that it was *not* imported.

It means that chain_list/2 is not in the export list of pce_util.  This
can mean three things: the module doesn't exist (isn't yet loaded), the
module doesn't have the predicate in ints export list or it doesn't
define the predicate at all.

import/2 will create the missing bits and a reference link.  This means
that if the module does not exist, an empty module with an undefined
predicate is created that is imported.  If the predicate gets a
definition later all should work as expected.

	Regards --- Jan

