[net.lang.ada] predefined operations

BBardin@ADA20.ISI.EDU (10/08/86)

If I may, a few more words on the issue of predefined operations,
specifically, where are they declared and when are they found in
STANDARD as opposed to 'somewhere else':

First, as Doug Bryan pointed out, there is a problem with the
semantics of the term 'predefined'.  One needs to distinguish between
predefined types and predefined operations.  When referring to types,
'predefined' implies a declaration (emphasis on 'declaration') which
has been made ahead of time, i.e., declared previously.  When refering
to operations, 'predefined' referes to a set of operations that will
be (emphasis on 'will be') declared (implicitly) at some point.
Predefined types are types which have actually been declared;
'predefined operations' refers to an a priori definition of a set, not
a pre-declaration of the actual operations.

Now, the rule for where the declarations for the set of predefined
operations for a given type are found is straight forward:

  "The operations implicitly declared for a given type declaration
   occur after the type declaration..." (ARM 3.3.3(2))

(The term 'implicitly declared' is used instead of 'predefined'
because there may be operations other than the predefined set which
are also implicitly declared (specifically, user defined operations
derived from a parent type)).

Thus, the location of the declaration of a predefined operator is
always known; it is found immediately after the type declaration for
which the operator applies.  If this type is found in 'Standard'
(e.g., 'Integer', 'Boolean', 'Character', 'String'), then the
declarations for the predefined operations are found in standard.  If
the type is found in the predefined package 'Calendar', (e.g.,
'Time'), then the declarations for the predefined operations are found
in 'Calendar'.  If the type is found in the user defined package
'Foo', then that is where the declarations for the predefined
operations are found. 


John Prentice, 
Hughes
-------

Bryan@SIERRA.STANFORD.EDU (Doug Bryan) (10/09/86)

Since we are still on the subject of predefined operations, I may as well
throw out the execption to the rule:

	procedure Not_Immediately_After is
	   type F1 is delta 1.0/16    range 0.0 .. 1_000.0;
	   type F2 is delta 2#0.1#E-3 range 0.0 .. 1_000.0;
	   X : F1 := 1.0;
	   Y : F2 := 2.0;
	begin
	   X := F1 (Standard."*"(X, Y));
	end Not_Immediately_After;

The reason this works is that any two fixed point operands may be multiplied.
Since the two fixed point types may be declared in different, non-overlapping
scopes, the only deterministic place to define "*" is in Standard.  The result
of this operation is of the type universal_fixed and is never implicitly
converted to a name type (like universal_integer and universal_real are).

doug
-------