comp.lang.ada
 help / color / mirror / Atom feed
From: "Petter Fryklund" <qsbpefr@esavionics.se>
Subject: Why not try Checked_Conversion?
Date: Thu, 7 Jun 2001 14:50:47 +0200
Date: 2001-06-07T14:50:47+02:00	[thread overview]
Message-ID: <9fnsdf$h2a$1@newstoo.ericsson.se> (raw)
In-Reply-To: 9fnbtt$ild$1@e3k.asi.ansaldo.it

Ie if you have

subtype Num_T is Natural range 0 .. 3;

type Enum_T is (Not_Started, Started, Stopped, Gone);

function Checked_Conversion (Num : Num_T) return Enum_T is
begin
    case Num is
        when 0 => return Not_Started;
        when 1 => return Started;
        when 2 => return Stopped;
        when 3 => return Gone;
    end case;
end Checked_Conversion;

Lele wrote in message <9fnbtt$ild$1@e3k.asi.ansaldo.it>...
>Hi!
>I'm a misterious reader...just because I've read for a month this NG
without
>take part.
>I'm a beginner ADA programmer (what a wonderful language!) and I've a
>problem...
>
>I should convert data types and record data types from one type to another,
>since now I've
>used the address attribute to point the same memory space and so accede to
>from one type
>to another. Ada provides features for bypassing certain language
>restrictions and these
>features are unchecked; it is the programmer's responsibility to make sure
>that they do
>not violate the assumptions of the rest of the program. Are there
particular
>risks about using Unchecked_Conversion? Is it a better approach  the
address
>attribute?
>
>Thanks!
>
>





  reply	other threads:[~2001-06-07 12:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-07  7:46 Unchecked_Conversion Lele
2001-06-07 12:50 ` Petter Fryklund [this message]
2001-06-07 13:01 ` Unchecked_Conversion Marc A. Criley
2001-06-07 13:21 ` Unchecked_Conversion Ted Dennison
2001-06-10 18:20   ` Unchecked_Conversion Robert B. Love 
2001-06-10 19:48     ` Unchecked_Conversion Jeff Creem
2001-06-10 22:10     ` Unchecked_Conversion Keith Thompson
2001-06-11 13:56     ` Unchecked_Conversion Ted Dennison
2001-06-11 14:21     ` Unchecked_Conversion Marin David Condic
2001-06-07 14:01 ` Unchecked_Conversion Jacob Sparre Andersen
2001-06-07 19:44 ` Unchecked_Conversion tmoran
2001-06-09 17:07   ` Unchecked_Conversion Robert A Duff
replies disabled

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