From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Mart van de Wege Newsgroups: comp.lang.ada Subject: Re: Confused about class-wide types Date: Sun, 20 Mar 2016 14:58:46 +0100 Message-ID: <86fuvl6yjt.fsf@gaheris.avalon.lan> References: <86oaa97635.fsf@gaheris.avalon.lan> Mime-Version: 1.0 Content-Type: text/plain X-Trace: individual.net X/yCxOR4Sa1txcs3U3yHdQFY2HZyiGZN/44+rJ1RK0L3MPs3Dy X-Orig-Path: gaheris.avalon.lan!not-for-mail Cancel-Lock: sha1:sBbzY+mq23vmDVp9T7zbKUVFrIM= sha1:YU3bgYfN8T3zCF+6OkXggZZFvIc= User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) Xref: news.eternal-september.org comp.lang.ada:29831 Date: 2016-03-20T14:58:46+01:00 List-Id: "Dmitry A. Kazakov" 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.