Re: [eclipse-users] Q regarding mode declarations

From: Joachim Schimpf <js10_at_...2...>
Date: Thu, 16 Nov 2006 18:34:22 +0000
Ulrich Scholz wrote:
> Hi everybody,
> 
> I have a question regarding mode declarations.  Chapters 2 and 6.6 of the
> ECLiPSEe User Manual explain modes.
> 
> 
> Is it true that there can be at most one mode declaration per predicate
> specification, i.e., pair of predicate name and arity?
> 
> I ask because many predifined predicates give two or more modes.  For
> example the reference manual lists the following for append/3:
> 
> append(+, +, -)
> append(-, -, +)
> 
> 
> My guess is: Yes, there can be at most one mode declaration.  The modes
> given in the manual are only to explain the different classes of determinism
> of the predicate.
> 
> But then, do predifined predicates have mode declarations?  And what would
> happen if I give two mode declarations for the same predicate?

The compiler understands only one mode declaration, and a new
declaration replaces a previously given one - you can check by
retrieving the declared mode with get_flag(PredSpec, mode, Mode).

I guess it was originally done this way so that one could
recompile a file with a modified mode declaration and have the
compiler see the new mode only.  In the age of modules, however,
it would probably make more sense to combine several mode declarations
into a summary mode for the compiler, e.g. p(-) and p(+) into p(?),
then the declarations would be more useful for documentation purposes
(currently multiple modes can only be documented via the comment/2
directive).


-- Joachim
Received on Thu Nov 16 2006 - 18:34:35 CET

This archive was generated by hypermail 2.2.0 : Mon Jul 09 2018 - 02:05:29 CEST