On 28/08/2025 10:02, Dmitry A. Kazakov wrote:
On 2025-08-28 10:50, Kevin Chadwick wrote:
I can explain how it works. When a DLL is loaded its library level
gets elaborated. So if you have:
package P is
type T is tagged ...
end P;
in the main program or DLL and
with P;
package Q is
type S is new T with ...
function F return T'Class;
end Q;
in the DLL being loaded, then in the process of elaboration S will be
created which in particular means extending of the dispatching table.
You can return a class-wide object from there and dispatch on the
newly created type's operation.
Clear?
Interesting, better than the shape examples but I guess you have to get
that in the first instance.
Dynamic polymorphism is an extremely powerful mechanism, but it kind of
bends out of traditional typing.
It is like the relativity theory. Everything is relative, position,
velocity, but up to the point. Acceleration is not anymore. Same is with
typing: value->type, so far so good, but one more step up:
value->type->class and something happens. Primitive operations become
reachable even if you do not see them, you cannot hide them. Multiple
inheritance, OK, but what about conflicts, is it additive or idempotent?
Multiple dispatch is a total dark hole.
I have struggled to find compelling reasons to use tagged types considering they affect the size of records and potentially elaboration issues that cannot exist without tagged types.
I know some use tagged types just for dot notation but that doesn't really move the needle in my mind. I would certainly appreciate it if people could share their favourite use cases for tagged types though. Things that are perhaps a pain without them or were with Ada 83.
I have struggled to find compelling reasons to use tagged types considering they affect the size of records and potentially elaboration issues that cannot exist without tagged types.
I know some use tagged types just for dot notation but that doesn't really move the needle in my mind.
I would certainly appreciate it if people could share their favouriteRather than a use-case, here is a general argument (well known already):
use cases for tagged types though. Things that are perhaps a pain
without them or were with Ada 83.
<...>In general, things like variant records are sorta "perpendicular" in use
I have struggled to find compelling reasons to use tagged types considering they affect the size of records and potentially elaboration issues that cannot exist without tagged types.
I know some use tagged types just for dot notation but that doesn't really move the needle in my mind. I would certainly appreciate it if people could share their favourite use cases for tagged types though. Things that are perhaps a pain without them or were with Ada 83.
The only
real issue is that IIRC tagged types are always at least twenty bytes on GNAT (on ARMv4T/ARMv5T at least, since developing for them is the only
time I've gotten warnings about this limitation) which precludes things
like having a record be small enough to be passed in a register instead
of the stack, but not much of an issue on modern systems.
One language extension I always wanted were an ability to have classes
of types without having a tag embedded in the representation.
One language extension I always wanted were an ability to have classes
of types without having a tag embedded in the representation.
I understand the usability problems tags can cause but not sure I
understand
the benefit. Would it allow memory mapped registers such as Timer_1 and Timer_2 with some differences but whose shared components could be handled
by a procedure accepting 'Class even though those shared components were memory mapped to different locations.
If so I would love that. Even if it
would not enable that. Have you considered making a suggestion here?
"https://github.com/Ada-Rapporteur-Group/User-Community-Input/issues"
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 1,066 |
Nodes: | 10 (0 / 10) |
Uptime: | 178:59:08 |
Calls: | 13,708 |
Files: | 186,949 |
D/L today: |
557 files (152M bytes) |
Messages: | 2,416,065 |