comp.lang.ada
 help / color / mirror / Atom feed
* A question for compiler vendors/lang experts. redefinition of "="
@ 1997-12-16  0:00 Barry and Jackie Schiff
  1997-12-16  0:00 ` David  Weller
  1997-12-16  0:00 ` Tucker Taft
  0 siblings, 2 replies; 3+ messages in thread
From: Barry and Jackie Schiff @ 1997-12-16  0:00 UTC (permalink / raw)



Got one answer from a large compiler vendor when another vendor's
implementation implies otherwise. Looked in the Rationale and LRM and it
was hard to find a clear answer. So here is the question for all those
language experts out there:


package Foo is

    type objects is abstract tagged record
        Some_value : some_type;
    end record;

    type class_wide_pointers is access all objects'class;

    function "="(left, right : access objects) return boolean; --
Legal??

end Foo;


The question: Is the redefinition of "=" shown above legal and if so
what are the semantics.  Specifically, is "=" a dispatching primitive
operation or is it ambiguous with the predefined equality defined for
the class_wide_pointers type.

--------------
In my reading the LRM it seems to me that the spirit of access
parameters is that the above operation is a dispatching operation. I
have had a large Ada compiler vendor tell me that the above is
ambiguous. While another compiler implements that above as a dispatching
operation. Can anyone point me to the definitive answer in the LRM.


Thanks in advance. If it is not to much trouble could you email answer.


--Barry Schiff





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: A question for compiler vendors/lang experts. redefinition of "="
  1997-12-16  0:00 A question for compiler vendors/lang experts. redefinition of "=" Barry and Jackie Schiff
@ 1997-12-16  0:00 ` David  Weller
  1997-12-16  0:00 ` Tucker Taft
  1 sibling, 0 replies; 3+ messages in thread
From: David  Weller @ 1997-12-16  0:00 UTC (permalink / raw)



In article <34964C63.F97005E6@netspace.net.au>,
Barry and Jackie Schiff  <schiff@netspace.net.au> wrote:
>Got one answer from a large compiler vendor when another vendor's
>implementation implies otherwise. Looked in the Rationale and LRM and it
>was hard to find a clear answer. So here is the question for all those
>language experts out there:
>
>
>package Foo is
>
>    type objects is abstract tagged record
>        Some_value : some_type;
>    end record;
>
>    type class_wide_pointers is access all objects'class;
>
>    function "="(left, right : access objects) return boolean; --
>Legal??
>

Yes, it is dispatching, but why not just declare:

	function "="(L, R : access Objects'Class) return boolean;   ??


Of course, perhaps I've missed a subtlety...it wouldn't be the first
time :-/


>parameters is that the above operation is a dispatching operation. I
>have had a large Ada compiler vendor tell me that the above is
>ambiguous. 

Perhaps they've gotten too large? :-)  Don't want to fix their
compiler? :-)

>Thanks in advance. If it is not to much trouble could you email answer.
>
Oh, great, complicate things why don't ya?

:-)


-- 
   ******   NEW!!  DoD Ada Hotline Number:  1-800-PARIAH    ******
Tired of "junk" e-mail?  Write to your congressman and tell them you support
H.R. 1748, "The Netizens Protection Act of 1997".  Make those SPAM-roaches run!             http://www.cauce.org          TAKE BACK THE INTERNET!




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: A question for compiler vendors/lang experts. redefinition of "="
  1997-12-16  0:00 A question for compiler vendors/lang experts. redefinition of "=" Barry and Jackie Schiff
  1997-12-16  0:00 ` David  Weller
@ 1997-12-16  0:00 ` Tucker Taft
  1 sibling, 0 replies; 3+ messages in thread
From: Tucker Taft @ 1997-12-16  0:00 UTC (permalink / raw)



Barry and Jackie Schiff (schiff@netspace.net.au) wrote:

: Got one answer from a large compiler vendor when another vendor's
: implementation implies otherwise. Looked in the Rationale and LRM and it
: was hard to find a clear answer. So here is the question for all those
: language experts out there:


: package Foo is

:     type objects is abstract tagged record
:         Some_value : some_type;
:     end record;

:     type class_wide_pointers is access all objects'class;

:     function "="(left, right : access objects) return boolean; --
: Legal??

: end Foo;


: The question: Is the redefinition of "=" shown above legal and if so
: what are the semantics.  Specifically, is "=" a dispatching primitive
: operation or is it ambiguous with the predefined equality defined for
: the class_wide_pointers type.

It is a dispatching operation of type Objects.  It does not
override the predefined operator for type class_wide_pointers, whose
profile is:

   function "="(left, right : class_wide_pointers) return boolean;

However, essentially all cases where you use the function will be 
ambiguous.  For example, if you "use" package Foo, then:

        x, y : class_wide_pointers;
    begin
        if x = y then ...

is ambiguous, as is:

    procedure blah(a, b : objects) is
    begin
        if a'access = b'access then ...

It is not easy to construct a case where a use of your operator won't be
ambiguous with a use of the predefined "=" operator for a named access type.

: --------------
: In my reading the LRM it seems to me that the spirit of access
: parameters is that the above operation is a dispatching operation. I
: have had a large Ada compiler vendor tell me that the above is
: ambiguous. 

These are not incompatible statements.  It is a dispatching operation,
and almost all uses of it will be ambiguous.

: ... While another compiler implements that above as a dispatching
: operation. Can anyone point me to the definitive answer in the LRM.

You are both right.

: Thanks in advance. If it is not to much trouble could you email answer.

Will do.

: --Barry Schiff

--
-Tucker Taft   stt@inmet.com   http://www.inmet.com/~stt/
Intermetrics, Inc.  Burlington, MA  USA




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1997-12-16  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-12-16  0:00 A question for compiler vendors/lang experts. redefinition of "=" Barry and Jackie Schiff
1997-12-16  0:00 ` David  Weller
1997-12-16  0:00 ` Tucker Taft

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox