comp.lang.ada
 help / color / mirror / Atom feed
From: Mart van de Wege <mvdwege@gmail.com>
Subject: Re: Confused about class-wide types
Date: Sun, 20 Mar 2016 14:58:46 +0100
Date: 2016-03-20T14:58:46+01:00	[thread overview]
Message-ID: <86fuvl6yjt.fsf@gaheris.avalon.lan> (raw)
In-Reply-To: ncm547$o7p$1@gioia.aioe.org

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:

>
> Ada has named types equivalence. Event_Ptr and Message_Event_Ptr are
> two independent types regardless what they point to. If you declared
>
Yes, that's what threw me off.

>    type Message_Event_Ptr is access Event'Class;
>
> It would not work. Event if you did
>
>    type Message_Event_Ptr is new Event_Ptr;
>
> It still would not.
>
> All this is unrelated to class-wide vs specific types.
>
> BTW, it is a bad idea to use pointers, as bad as using vectors for a
> FIFO or Unbounded_String to keep constant strings. To dynamically
> allocate Unbounded_String which contents is again dynamically
> allocated is quite bizarre. Pointers could be used with queues when
> messages are pre-allocated elsewhere, in order to avoid copying
> overhead.

Yeah, but when I want to have a number of different Event types with
some common operations that I want to store in a Vector, I either need
pointers, or, as Shark8 points out, an Indefinite_Vector, which I
overlooked.

Mart

-- 
"We will need a longer wall when the revolution comes."
    --- AJS, quoting an uncertain source.


  reply	other threads:[~2016-03-20 13:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-20 11:15 Confused about class-wide types Mart van de Wege
2016-03-20 12:29 ` Dmitry A. Kazakov
2016-03-20 13:58   ` Mart van de Wege [this message]
2016-03-20 14:26     ` Dmitry A. Kazakov
2016-03-20 12:46 ` Simon Wright
2016-03-20 14:01   ` Mart van de Wege
2016-03-20 13:18 ` Shark8
2016-03-20 13:56   ` Mart van de Wege
2016-03-21 21:54   ` Randy Brukardt
replies disabled

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