Subject: [SWIPL] module coerency problem

From: Armando Stellato <[email-masked]>
Date: Tue, 02 Oct 2001 14:25:17 +0200

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?

Thanks in advance

Armando Stellato