comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: User defined type conversion
Date: Thu, 09 May 2013 11:24:54 -0700
Date: 2013-05-09T11:24:54-07:00	[thread overview]
Message-ID: <kmgpes$nvs$1@dont-email.me> (raw)
In-Reply-To: <c9c8b269-fb9e-4715-b48c-40047fff1658@googlegroups.com>

On 05/09/2013 07:07 AM, Vin�cius Franchini wrote:
>
> type AB is tagged
>    record
>      A : Unsigned_16;
>      B : Unsigned_16;
>    end record;
>
> type abcde is tagged
>    record
>      a: Unsigned_8;
>      b: Unsigned_8;
>      c: Unsigned_8;
>      d: Unsigned_8;
>    end record;
>
> X : AB;
> Y : abcd;
>
> X := Y;

The type of Y (Abcd) is undefined, so it's impossible to tell what you're trying 
to do. Also, types Unsigned_16 and Unsigned_8 are undefined.

Even if we presume that you meant Y to be of type Abcde, and the Unsigned_* 
types to be those in package Interfaces, it's still unclear what you're trying 
to do. Which parts of Y do you expect to be combined into which parts of X, and 
in what way? Since you haven't specified this, other responses you've received 
that presume that certain parts of Y are specific bytes of parts of X may not be 
correct.

Are you striving, as a good software engineer, to accomplish your goal in a 
portable way? Bear in mind that some platforms are big endian and others little 
endian, some byte addressable and others not. Since these are tagged records 
(why?), bear in mind that they contain a tag field, and the language does not 
specify where that field is located in objects of the type, nor where the other 
fields are located. All these factors make the solution using similar untagged 
records with representation clauses and Unchecked_Conversion non-portable.

When you answer these questions, we can suggest ways to accomplish the task.

-- 
Jeff Carter
"There's no messiah here. There's a mess all right, but no messiah."
Monty Python's Life of Brian
84



  parent reply	other threads:[~2013-05-09 18:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-09 14:07 User defined type conversion Vinícius Franchini
2013-05-09 14:50 ` Adam Beneschan
2013-05-09 16:12 ` Shark8
2013-05-09 16:50   ` Adam Beneschan
2013-05-09 18:24 ` Jeffrey Carter [this message]
2013-05-09 18:39   ` Vinícius Franchini
2013-05-09 19:15     ` Adam Beneschan
2013-05-09 20:00       ` Vinícius Franchini
2013-05-09 20:19     ` Jeffrey Carter
2013-05-12  7:04 ` ldries46
2013-05-12 14:13   ` AdaMagica
2013-05-12 15:02 ` anon
replies disabled

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