From starred@tiscalinet.it Wed Oct  3 01:08:38 2001
Received: from smtp3.libero.it (smtp3.libero.it [193.70.192.53])
	by swi.psy.uva.nl (8.11.2/8.11.2) with ESMTP id f92N8cv15920;
	Wed, 3 Oct 2001 01:08:38 +0200 (MET DST)
Received: from tiscalinet.it (151.24.140.207) by smtp3.libero.it (6.0.021)
        id 3BA82CE8003F6E6C; Wed, 3 Oct 2001 01:08:31 +0200
X-Mozilla-Status: 0801
Message-ID: <3BB9E8B3.4030006@tiscalinet.it>
Date: Tue, 02 Oct 2001 18:17:55 +0200
From: Armando Stellato <starred@tiscalinet.it>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.2) Gecko/20010726 Netscape6/6.1
X-Accept-Language: en-us
MIME-Version: 1.0
To: Jan Wielemaker <jan@swi.psy.uva.nl>
CC: SWI Mailing List <prolog@swi.psy.uva.nl>
Subject: Re: [SWIPL] module coerency problem
References: <3BB9B22D.5090104@tiscalinet.it> <01100216154100.00929@gollem>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Thanks Jan, multifile is exactly what I needed, it is written clearly in 
the manual, but i didn't remember even its existence.
However this is good if i decide to make "agents_io" consult the module 
with other handle_msg definitions (let us call it "extended_module").
On the other hand, If i decide to make "agents_io" use_module (and not 
consult directly) "extended_module", and make handle_msg in 
"extended_module" public, i continue to receive:
ERROR: (i:/tesidilaurea/myworkspace/coordinator_agent.pl:17):
Cannot import coordinator_agent:handle_msg/2 into module agents_io:
name clash

is it possible to solve this problem also when using use_module instead 
of consult?
Thank you again
Armando



Jan Wielemaker wrote:

> On Tue, 02 Oct 2001, Armando Stellato wrote:
> 
>>Hi, I've a problem with modules:
>>I'm building an agent environment.
>>I'm making great use of modules, so to create various layers and be able 
>>to work on each of them without modify the code in the substrates.
>>
>>I've a module named agents who use_module various modules, every agent 
>>written uses only imported methods (predicates) from module:agents, then 
>>'agents' calls methods from its various submodules who are visible only 
>>by himself.
>>
>>The problem is:
>>One of the submodules is agents_io that has a method called: handle_msg/2.
>>I would like to expand agents_io with conditional consulting/use_module 
>>with new instances of handle_msg/2.
>>I'll make an example:
>>in 'agents_io' i've:
>>handle_msg(AgentId,txt_msg(TXT)),
>>handle_msg(AgentId,disconnect).
>>
>>I've build a module called 'coordinator_agent' that is consulted only if 
>>the agent using module agent is of type:coordinator.
>>This module is consulted by "agents_io" and should give some more 
>>handle_msg methods.
>>Exampe:
>>exp_handle_msg(AgentId,agent_declare(ROLE,ONTOLOGY,LANGUAGE))
>>
>>The problem is:
>>if i make agents_io consult 'coordinator_agent', the compiler says me 
>>that i've redefined handle_msg/2, so it doesn't uses original handle:msg 
>>
>>from agents_io
> 
>>if i make agents_io use_module coordinator_agent (rewritten as a 
>>module), the compiler says me that predicate names clash (cause 
>>handle_msg is already defined in agents_io).
>>
>>Is there really no way to add some more handle_msg predicates to 
>>agents_io, without modifying everytime the code in the module agents_io???
>>I don't want to go around the problem using another name for the 
>>predicates handle_msg in coordinator_agent and invoke them if handle_msg 
>>fails on agents_io. This is a solution but i don't like it, it is "dirty".
>>any other solution?
>>
> 
> Not sure I've understood the whole story, but I think the key to your
> problem is the :- multifile some_module:agents_io/2.  According to the
> standard, this directive should be above the clauses in all files
> defining clauses for this predicate.  SWI-Prolog currently doesn't
> enforce this.
> 
> 	Regards --- Jan
> 
> 



