comp.lang.ada
 help / color / mirror / Atom feed
* Primitive subprogram for a subtype?
@ 2017-08-20 22:45 Victor Porton
  2017-08-21  7:08 ` Dmitry A. Kazakov
  2017-08-21  7:36 ` mockturtle
  0 siblings, 2 replies; 7+ messages in thread
From: Victor Porton @ 2017-08-20 22:45 UTC (permalink / raw)


Is it possible to define a primitive subprogram for a subtype rather than 
the base type?

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

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

* Re: Primitive subprogram for a subtype?
  2017-08-20 22:45 Primitive subprogram for a subtype? Victor Porton
@ 2017-08-21  7:08 ` Dmitry A. Kazakov
  2017-08-21 12:32   ` Victor Porton
  2017-08-21  7:36 ` mockturtle
  1 sibling, 1 reply; 7+ messages in thread
From: Dmitry A. Kazakov @ 2017-08-21  7:08 UTC (permalink / raw)


On 21/08/2017 00:45, Victor Porton wrote:
> Is it possible to define a primitive subprogram for a subtype rather than
> the base type?

No, a subtype (Ada subtype) would have same tag.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


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

* Re: Primitive subprogram for a subtype?
  2017-08-20 22:45 Primitive subprogram for a subtype? Victor Porton
  2017-08-21  7:08 ` Dmitry A. Kazakov
@ 2017-08-21  7:36 ` mockturtle
  1 sibling, 0 replies; 7+ messages in thread
From: mockturtle @ 2017-08-21  7:36 UTC (permalink / raw)


On Monday, August 21, 2017 at 12:45:44 AM UTC+2, Victor Porton wrote:
> Is it possible to define a primitive subprogram for a subtype rather than 
> the base type?
> 
> -- 
> Victor Porton - http://portonvictor.org

As I understand (but I am no language lawyer) a subtype is actually the base type, but just with a restriction on the set of possible values.  Therefore, it seems to me that it does not make sense to have type and subtype with different primitive subprograms.

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

* Re: Primitive subprogram for a subtype?
  2017-08-21  7:08 ` Dmitry A. Kazakov
@ 2017-08-21 12:32   ` Victor Porton
  2017-08-21 12:42     ` Egil H H
                       ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Victor Porton @ 2017-08-21 12:32 UTC (permalink / raw)


Dmitry A. Kazakov wrote:

> On 21/08/2017 00:45, Victor Porton wrote:
>> Is it possible to define a primitive subprogram for a subtype rather than
>> the base type?
> 
> No, a subtype (Ada subtype) would have same tag.

How is it related to having the same tag? I do NOT speak about defining a 
primitive subprogram for both the type and its subtype but for the subtype 
only.

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

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

* Re: Primitive subprogram for a subtype?
  2017-08-21 12:32   ` Victor Porton
@ 2017-08-21 12:42     ` Egil H H
  2017-08-21 12:50     ` Dmitry A. Kazakov
  2017-08-21 14:00     ` J-P. Rosen
  2 siblings, 0 replies; 7+ messages in thread
From: Egil H H @ 2017-08-21 12:42 UTC (permalink / raw)


On Monday, August 21, 2017 at 2:32:29 PM UTC+2, Victor Porton wrote:
> 
> How is it related to having the same tag?

It's not. Types can have primitive subprograms without being tagged.

-- 
~egilhh


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

* Re: Primitive subprogram for a subtype?
  2017-08-21 12:32   ` Victor Porton
  2017-08-21 12:42     ` Egil H H
@ 2017-08-21 12:50     ` Dmitry A. Kazakov
  2017-08-21 14:00     ` J-P. Rosen
  2 siblings, 0 replies; 7+ messages in thread
From: Dmitry A. Kazakov @ 2017-08-21 12:50 UTC (permalink / raw)


On 21/08/2017 14:32, Victor Porton wrote:
> Dmitry A. Kazakov wrote:
> 
>> On 21/08/2017 00:45, Victor Porton wrote:
>>> Is it possible to define a primitive subprogram for a subtype rather than
>>> the base type?
>>
>> No, a subtype (Ada subtype) would have same tag.
> 
> How is it related to having the same tag?

Because a primitive subprogram must have a unique slot in the 
dispatching table. If tags are same dispatch cannot lead to different 
bodies.

> I do NOT speak about defining a
> primitive subprogram for both the type and its subtype but for the subtype
> only.

A subtype is a type that inherits subprograms = considered substitutable 
for its supertype. If it does not, then it is not a subtype in any 
sense, including Ada's, Liskov's, whatever flavor of.

P.S. Considering non-primitive subprograms and non-tagged types. Ada 
subtype is an "equivalent" type. It is both sub- and supertype of its 
base type and all other subtypes of whatever subtypes and their subtypes 
(a closure set). Thus anything you define on it is exported to the base 
type and to all subtypes from this type equivalence class.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


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

* Re: Primitive subprogram for a subtype?
  2017-08-21 12:32   ` Victor Porton
  2017-08-21 12:42     ` Egil H H
  2017-08-21 12:50     ` Dmitry A. Kazakov
@ 2017-08-21 14:00     ` J-P. Rosen
  2 siblings, 0 replies; 7+ messages in thread
From: J-P. Rosen @ 2017-08-21 14:00 UTC (permalink / raw)


Le 21/08/2017 à 14:32, Victor Porton a écrit :
> How is it related to having the same tag? I do NOT speak about defining a 
> primitive subprogram for both the type and its subtype but for the subtype 
> only.
A value (as opposed to a variable) has no subtype, just a type. Suppose
P is a primitive subprogram of some integer type, if you define another
P for some subtype of it, which one would you call for P(1) ?

Remember that the bounds of a subtype can be computed at runtime, but
that overload resolution happens at compile-time!
-- 
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
http://www.adalog.fr

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

end of thread, other threads:[~2017-08-21 14:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-20 22:45 Primitive subprogram for a subtype? Victor Porton
2017-08-21  7:08 ` Dmitry A. Kazakov
2017-08-21 12:32   ` Victor Porton
2017-08-21 12:42     ` Egil H H
2017-08-21 12:50     ` Dmitry A. Kazakov
2017-08-21 14:00     ` J-P. Rosen
2017-08-21  7:36 ` mockturtle

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