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 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED.Oh2LSLzxQ4+YU0Htrufc+A.user.gioia.aioe.org!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Creating several types from a base type and conversion Date: Sat, 18 Jan 2020 12:16:18 +0000 Organization: Aioe.org NNTP Server Message-ID: References: NNTP-Posting-Host: Oh2LSLzxQ4+YU0Htrufc+A.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain X-Complaints-To: abuse@aioe.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (darwin) X-Notice: Filtered by postfilter v. 0.9.2 Cancel-Lock: sha1:zOK7OmsBEuT0MC7dW/lxppzUq9I= Xref: reader01.eternal-september.org comp.lang.ada:57868 Date: 2020-01-18T12:16:18+00:00 List-Id: Ken Roberts writes: > So the next question is how to convert between CharWord/BaseWord? Possibly using Ada.Unchecked_Conversion. Hidden inside a function with a helpful-in-six-months name. It takes very little time to compile code nowadays, I'd strongly suggest you start with the basics (e.g. BaseWord) and build up from there, checking as you go (there are a _lot_ of syntax errors in your example code). You can't say type DataWord is new BaseWord with record Upper : array 00 .. 8#77777# of Boolean; Lower : array 00 .. 8#77777# of Boolean; end record; because BaseWord isn't a tagged type, and even if it was you don't want to add extra information, you're looking for an alternative view. And that's not the syntax for an array declaration. And you can't declare an anonymous array in a record. And that's two large arrays (I think you're aiming for representations). ---------- I was wondering whether an Unchecked Union (ARM B.3.3[1]) might serve, but (30) says "The use of an unchecked union to obtain the effect of an unchecked conversion results in erroneous execution". [1] http://www.ada-auth.org/standards/rm12_w_tc1/html/RM-B-3-3.html