🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by John Prentice Thu, 16 Oct 1986 17:03
Re: Predefined OPerators
#1019
Author: John Prentice
Date: Thu, 16 Oct 1986 17:03
60 lines
2735 bytes

I know this subject may be getting a bit old, but I would like to 
take exception to the position that the '*' operator defined in 
Standard represents an exception to the rule (ARM 3.3.3(2)) defining
the location of the declaration of predefined operators.

Given:

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


The assertion seemed to be that the operator '*' referenced on line 7
is a predefined operator for type F1 or F2 (or both).  If this were true,
then clearly we have an exception to the rule for predefined operators
since F1 and f2 are both defined in 'Not_Immediately_After' while the 
operator '*' is defined in Standard (and hence the legality of the
reference to 'Standard."*"').

I think the correct interpretation of this situation is that the operator
refereced on line 7 was not predefined for type F1 or F2, but is
predefined for the type 'universal_fixed' which is declared in Standard
(ARM C-3(11)):

-- The type 'universal_integer' is predefined.  The only operators
-- declared for this type are:

-- function "*" (Left : 'any_fixed_point_type'; Right : 'any_fixed_point_type')
-- return 'universal_fixed';


Thus the declaration of the predefined operator '*' does indeed follow
immediately after the declaration of the type.  The anomaly here 
is that the function '*' seems to be a polymorphic function--it accepts
arguments of (potentially) many different types.


Now I have a question:  What is the rational for having this single
polymorphic function in a language as strongly typed as Ada?  Could
the ARM read:

-- function "*" (Left : 'universal_fixed'; Right : 'universal_fixed')
-- return 'universal_fixed';

and state that a call to this function with any fixed point type would
result in an implicit conversion of that type to 'universal_fixed'?
The implicit conversion would seem to me to be less inconsistent than
a polymorphic function. 


John Prentice,
Hughes Aircraft
-------
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads