From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.43.64.202 with SMTP id xj10mr15365796icb.0.1406577902241; Mon, 28 Jul 2014 13:05:02 -0700 (PDT) X-Received: by 10.182.250.195 with SMTP id ze3mr15338obc.34.1406577902014; Mon, 28 Jul 2014 13:05:02 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!h18no9491055igc.0!news-out.google.com!px9ni0igc.0!nntp.google.com!h18no9491036igc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 28 Jul 2014 13:05:01 -0700 (PDT) In-Reply-To: <90305214-9a02-4684-8521-847e8ba38f79@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=173.57.209.48; posting-account=zwxLlwoAAAChLBU7oraRzNDnqQYkYbpo NNTP-Posting-Host: 173.57.209.48 References: <90305214-9a02-4684-8521-847e8ba38f79@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <0f1945be-f22b-4b3a-84e1-991e9d746b5c@googlegroups.com> Subject: Re: What is a byte? From: "Dan'l Miller" Injection-Date: Mon, 28 Jul 2014 20:05:02 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:21318 Date: 2014-07-28T13:05:01-07:00 List-Id: 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: >=20 > > 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 comp= iler that (at stage N) generates some Convention C code, then executes it t= o learn about the characteristics of the target C compiler, then generate t= he appropriate subtypes in corresponding stage-N+1 Ada source code, then co= mpile 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 re= flect the execution environment back into source code, the best that you ca= n 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 pack= age for 8-bit bytes, one child package for FPGAs' 9-bit bytes; and one chil= d package for DSPs' 32-bit bytes; 3) use variant records or generics to force app-domain programmers to speci= fy 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 c= ontortions to achieve a limited amount of reflection with extremely-verbose= syntax