From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Dynamically tagged expression not allowed. Why?
Date: Tue, 1 Jun 2010 18:36:17 -0500
Date: 2010-06-01T18:36:17-05:00 [thread overview]
Message-ID: <hu45hk$3g8$1@munin.nbi.dk> (raw)
In-Reply-To: c2ead$4c0150a0$4ca4a823$11809@API-DIGITAL.COM
"Marc A. Criley" <mcNOSPAM@mckae.com> wrote in message
news:c2ead$4c0150a0$4ca4a823$11809@API-DIGITAL.COM...
...
> Stripping out a test case, I see that it has nothing to with the C++
> binding per se, but it's an Ada issue that's flummoxing me. Here's the
> test code:
>
> procedure Dyty_Test is
>
> type Class_Type is tagged limited record
> null;
> end record;
>
> function New_Class_Instance return Class_Type'Class;
>
> Conn : Class_Type := New_Class_Instance;
This is illegal because the function returns a class-wide object and you are
assigning it into an object of a specific type. You have to explicitly use a
type conversion here:
Conn : Class_Type := Class_Type (New_Class_Instance);
to specify that you want to truncate the returned object, or make the object
classwide:
Conn : Class_Type'Class := New_Class_Instance;
But notice that while both of these are legal, they'll both raise
Program_Error because an access-before-elaboration error (the body of
New_Class_Instance hasn't been elaborated at the point of this call).
Randy.
next prev parent reply other threads:[~2010-06-01 23:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-29 17:36 Dynamically tagged expression not allowed. Why? Marc A. Criley
2010-05-29 18:23 ` Dmitry A. Kazakov
2010-06-03 2:37 ` Yannick Duchêne (Hibou57)
2010-06-03 7:48 ` Dmitry A. Kazakov
2010-06-01 23:36 ` Randy Brukardt [this message]
2010-06-03 2:36 ` Yannick Duchêne (Hibou57)
2010-06-03 7:57 ` Dmitry A. Kazakov
2010-06-03 8:21 ` Yannick Duchêne (Hibou57)
2010-06-03 16:03 ` Adam Beneschan
2010-06-05 18:47 ` Marc A. Criley
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox