From: "Martin Dowie" <martin.dowie@nospam.baesystems.com>
Subject: Re: Restrictions on compilers for Microsoft's .NET project
Date: Mon, 11 Feb 2002 19:20:50 -0000
Date: 2002-02-11T19:20:50+00:00 [thread overview]
Message-ID: <3c68198b$1@pull.gecm.com> (raw)
In-Reply-To: 6Hi6zB5TJ9qK@eisner.encompasserve.org
> Certainly I am not expecting to be able to change variants on the fly,
> but I have a lot of code that receives an access value denoting a
> record and I have to check the value of a discriminant to determine
> which fields of the record are available to me. If I get it wrong
> Compaq Ada will detect my error just as surely as it will detect an
> out-of-range value of the discriminant. Those possibly-present
> fields from various variants are located at the same offsets as
> each other.
>
> The Microsoft publication I quoted described this as "unsafe". Is
> this prohibited by .NET ? Is it allowed in Ada95 as in Ada83 ?
Well, I can see how this would be "unsafe" in C-style languages but
with all checks in place Ada programs will prevent you from assigning
to variant fields if the discriminant doesn't allow it.
So in:
type A_Variant (Value : Foo := Foo'First) is record
case Value is
when Bar1 =>
Int : Integer;
when Bar2 =>
Bool : Boolean;
end case;
end record;
if you wanted to have a data item with Value = Bar2 but an integer
value assigned to the memory area that Bool occupies you can, but
only by using a big ugly thing like an unchecked conversion.
otherwise, if you want to have 'Bool' assigned a value, you have
to change the discriminant to Bar2 at the same time.
next prev parent reply other threads:[~2002-02-11 19:20 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-02-09 23:31 Restrictions on compilers for Microsoft's .NET project Larry Kilgallen
2002-02-10 5:26 ` Britt Snodgrass
2002-02-11 16:59 ` Stephen Leake
2002-02-11 17:25 ` Larry Kilgallen
2002-02-11 17:34 ` Martin Dowie
2002-02-11 18:07 ` Larry Kilgallen
2002-02-11 19:20 ` Martin Dowie [this message]
2002-02-11 19:31 ` Jerry Petrey
2002-02-12 2:21 ` Robert Dewar
2002-02-12 3:22 ` Larry Kilgallen
2002-02-12 16:33 ` Stephen Leake
2002-02-12 19:26 ` Larry Kilgallen
2002-02-13 2:00 ` Richard Riehle
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox