Re: Explicit module scoping

From: Joachim Schimpf <j.schimpf_at_icparc.ic.ac.uk>
Date: Tue 28 Aug 2001 12:59:29 PM GMT
Message-ID: <3B8B95B1.473A494F@icparc.ic.ac.uk>
Andrew John Sadler wrote:
> 
> The following code fails, but with a strange error...
> 
> Code:
> > go:-
> >       ic:(X =:= 3.4),
> >       writeln(X).
> >
> > :-lib(ic).
> > ?- go.
> 
> Error:
> > Definition of =:=/2 in module ic is incompatible with call in module eclipse
> > calling an undefined procedure X =:= 3.4 in module eclipse
> >
> > *** compilation aborted
> >       before line 8 in the file /a/breeze/extra5/ajs2/Tests/IC/module_failure.pl
> 
> The question I have is, should go be allowed to compile successfully
> given that ic has not been loaded yet,

Predicates can have different calling conventions, therefore it
can happen that a call is incompatible with a definition.
In general, the definition (or at least a declaration) should
be known at the time a call is being compiled. If not, the
compiler uses a default convention, which (as in this case)
is not always right. The reason here is probably that the
predicate has an inline expansion defined which can obviously
not be done unless it is known at compile time.


> and if it should (as it does), shouldn't the module expansion then
> be done at run-time?

You are right, we could in pricinple turn the call into a metacall
and do all the work at runtime. But I'd prefer not to have such
a significant performance difference caused just by putting
the :- lib(ic) in the wrong place. I'd rather stick to
requiring declaration before use. Any opinions?

-- Joachim
Received on Tue Aug 28 13:59:29 2001

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:08:09 PM GMT GMT