comp.lang.ada
 help / color / mirror / Atom feed
From: "Dan'l Miller" <optikos@verizon.net>
Subject: Re: What is a byte?
Date: Mon, 28 Jul 2014 13:05:01 -0700 (PDT)
Date: 2014-07-28T13:05:01-07:00	[thread overview]
Message-ID: <0f1945be-f22b-4b3a-84e1-991e9d746b5c@googlegroups.com> (raw)
In-Reply-To: <90305214-9a02-4684-8521-847e8ba38f79@googlegroups.com>

On Monday, July 28, 2014 2:48:16 PM UTC-5, Dan'l Miller wrote:
> On Monday, July 28, 2014 2:09:17 PM UTC-5, Victor Porton wrote:
> 
> > When I need to pass a byte to a C function, which Ada type should I use?

What you would *really* want to do in Ada is have a multistage Ada202X compiler that (at stage N) generates some Convention C code, then executes it to learn about the characteristics of the target C compiler, then generate the appropriate subtypes in corresponding stage-N+1 Ada source code, then compile that N+1 stage, where the app-domain Ada source-code is (i.e., where today's era of Ada source-code is).

Short of that state-of-the-art reflection (in e.g. multi-stage OCaml) to reflect the execution environment back into source code, the best that you can do is:
0) forego extreme portability entirely:  choose to support 8-bit bytes only with no Plan B and no apologies;
1) use a preprocessor (e.g., gnatprep; m4) to choose different Ada subtypes via conditional compilation;
2) use a child package for each different bit-size of byte:  one child package for 8-bit bytes, one child package for FPGAs' 9-bit bytes; and one child package for DSPs' 32-bit bytes;
3) use variant records or generics to force app-domain programmers to specify 8 or 9 or 32 in app-domain code
4) by far the worst of all:  evolve Ada202X to duplicate C++'s metatemplate-programming poor-man's functional-programming language to perform arcane contortions to achieve a limited amount of reflection with extremely-verbose syntax


  reply	other threads:[~2014-07-28 20:05 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-28 19:09 What is a byte? Victor Porton
2014-07-28 19:48 ` Dan'l Miller
2014-07-28 20:05   ` Dan'l Miller [this message]
2014-07-28 22:38   ` Randy Brukardt
2014-07-28 21:15 ` Simon Wright
2014-07-29 10:53 ` Jeffrey Carter
2014-07-29 12:26   ` Dan'l Miller
2014-07-29 18:40     ` Simon Wright
2014-07-29 21:15       ` Dan'l Miller
2014-07-29 23:08         ` Simon Clubley
2014-07-30  4:11       ` Dan'l Miller
2014-07-30  7:47       ` Simon Wright
2014-08-02 21:01   ` Keith Thompson
replies disabled

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