comp.lang.ada
 help / color / mirror / Atom feed
* Trouble with "operation can be dispatching in only one type"
@ 2014-08-13 19:23 Victor Porton
  2014-08-13 19:44 ` Victor Porton
  2014-08-13 20:01 ` Niklas Holsti
  0 siblings, 2 replies; 3+ messages in thread
From: Victor Porton @ 2014-08-13 19:23 UTC (permalink / raw)


I defined two tagged types T1 and T2 in some package.

I need a function in the same package:

not overriding function F (Stack: T1) return T2;

The compiler complaints:

operation can be dispatching in only one type

My current workaround is to define it instead as:

not overriding function F (Stack: T1'Class) return T2;

But this is a hack. Can I define this function in the right way? (I want it 
to be dispatching only in T1, not T2.)

-- 
Victor Porton - http://portonvictor.org

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

* Re: Trouble with "operation can be dispatching in only one type"
  2014-08-13 19:23 Trouble with "operation can be dispatching in only one type" Victor Porton
@ 2014-08-13 19:44 ` Victor Porton
  2014-08-13 20:01 ` Niklas Holsti
  1 sibling, 0 replies; 3+ messages in thread
From: Victor Porton @ 2014-08-13 19:44 UTC (permalink / raw)


Victor Porton wrote:

> I defined two tagged types T1 and T2 in some package.
> 
> I need a function in the same package:
> 
> not overriding function F (Stack: T1) return T2;
> 
> The compiler complaints:
> 
> operation can be dispatching in only one type
> 
> My current workaround is to define it instead as:
> 
> not overriding function F (Stack: T1'Class) return T2;
> 
> But this is a hack. Can I define this function in the right way? (I want
> it to be dispatching only in T1, not T2.)

package Bad is

   type T1 is tagged null record;
   type T2 is tagged null record;

   not overriding function F (Stack: T1) return T2;
   
end Bad;

-- 
Victor Porton - http://portonvictor.org

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

* Re: Trouble with "operation can be dispatching in only one type"
  2014-08-13 19:23 Trouble with "operation can be dispatching in only one type" Victor Porton
  2014-08-13 19:44 ` Victor Porton
@ 2014-08-13 20:01 ` Niklas Holsti
  1 sibling, 0 replies; 3+ messages in thread
From: Niklas Holsti @ 2014-08-13 20:01 UTC (permalink / raw)


On 14-08-13 22:23 , Victor Porton wrote:
> I defined two tagged types T1 and T2 in some package.
> 
> I need a function in the same package:
> 
> not overriding function F (Stack: T1) return T2;
> 
> The compiler complaints:
> 
> operation can be dispatching in only one type
> 
> My current workaround is to define it instead as:
> 
> not overriding function F (Stack: T1'Class) return T2;
> 
> But this is a hack. Can I define this function in the right way? (I want it 
> to be dispatching only in T1, not T2.)

To be dispatching in T1, but not in T2, it should be

   function F (Stack : T1) return T2'Class;

If the use of 'Class to prevent dispatching is a problem for you,
another way is to put the two type declarations in different packages.

A function F can be dispatching only in the type declared in the same
package as F. For example, if T2 is declared in a different package than
T1 (including a package nested within the package that declares T1) then
you can declare function F (Stack : T1) return Some_Pkg.T2 and it will
dispatch only in T1 (assuming that T1 and F are declared in the same
package declaration).

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
      .      @       .


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

end of thread, other threads:[~2014-08-13 20:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-13 19:23 Trouble with "operation can be dispatching in only one type" Victor Porton
2014-08-13 19:44 ` Victor Porton
2014-08-13 20:01 ` Niklas Holsti

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