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=0.7 required=5.0 tests=BAYES_00,INVALID_DATE, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a5aa52a6f866183 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-10-27 14:50:00 PST Path: nntp.gmd.de!xlink.net!howland.reston.ans.net!swiss.ans.net!newsgate.watson.ibm.com!watnews.watson.ibm.com!ncohen From: ncohen@watson.ibm.com (Norman H. Cohen) Newsgroups: comp.lang.ada Subject: Re: Flags in Ada? Date: 27 Oct 1994 13:24:24 GMT Organization: IBM T.J. Watson Research Center Distribution: world Message-ID: <38o9m8$mo6@watnews1.watson.ibm.com> References: <38khst$hn3@news.delphi.com> <38mle1$e3m@gnat.cs.nyu.edu> Reply-To: ncohen@watson.ibm.com NNTP-Posting-Host: rios8.watson.ibm.com Date: 1994-10-27T13:24:24+00:00 List-Id: In article <38mle1$e3m@gnat.cs.nyu.edu>, dewar@cs.nyu.edu (Robert Dewar) writes: |> well to me Dave's approach seems overkill |> |> I really don't see the objection to a packed record. The original question asked how to provide for logical operations among corresponding flags in different flag sets. Packed arrays of Booleans provide this and packed records of Booleans do not, except with tedious explicit programming: generic with Op (Left, Right: Boolean) return Boolean; function Packed_Record_Op; function Packed_Record_Op (Left, Right: Packed_Record_Type) return Packed_Record_Type is begin return ( Op(Left.Component_1, Right.Component_1), ..., Op(Left.Component_N, Right.Component_N) ); end Packed_Record_Op; function "and" is new Packed_Record_Op("and"); function "or" is new Packed_Record_Op("or"); function "xor" is new Packed_Record_Op("xor"); function "not" (Right: Packed_Record_Op) return Packed_Record_Op is begin return (not Right.Component_1, ..., not Right.Component_N); end "not"; Still, if you require explicit control over the mapping of Booleans in such an array to specific bits in a word (for the sake of a low-level external interface), only record representation clauses can provide them. It is unfortunate that there is no portable way to indicate whether,as index values increase, the positions of components in a packed array of Booleans go from LSB to MSB or MSB to LSB. -- Norman H. Cohen ncohen@watson.ibm.com