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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,71171f53c22d92b5 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-11-25 02:06:59 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!central.cox.net!news1.east.cox.net!east.cox.net!filt01.cox.net!peer01.cox.net!cox.net!border3.nntp.aus1.giganews.com!intern1.nntp.aus1.giganews.com!nntp.giganews.com!nntp.clear.net.nz!news.clear.net.nz.POSTED!not-for-mail NNTP-Posting-Date: Tue, 25 Nov 2003 04:06:57 -0600 From: Craig Carey Newsgroups: comp.lang.ada Subject: Re: C's trikery semantic opens up backdoor in new Linux kernel Date: Tue, 25 Nov 2003 23:06:52 +1300 Message-ID: <8776svslu9qqo4tp7mump5car7m5asa1fb@4ax.com> References: <3FB1A63C.9080200@nowhere.com> <20031114093318.000065b0._elh_@_terma_._com_> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Organization: Customer of Mercury Telecommunications Ltd Cache-Post-Path: drone5.qsi.net.nz!unknown@tnt1-582.quicksilver.net.nz X-Cache: nntpcache 2.4.0b5 (see http://www.nntpcache.org/) X-Original-NNTP-Posting-Host: drone5-svc-skyt.qsi.net.nz X-Original-Trace: 25 Nov 2003 23:07:25 +1300, drone5-svc-skyt.qsi.net.nz NNTP-Posting-Host: 203.97.37.6 X-Trace: sv3-ZVPQFyiO76HvnWVtqTZU+hSYNwEZKFZv7LzxOV+9YXwNR/QTVyxXUZrP4kBc9bryBqT3dF07QJgoRlj!8fyf6MrJMdwCVyUvb6HE+s024yOUWqeEg/8IEC6EDhK5zeRWH6Dolwx0EcJaWY1bC6wHZH8DefQO!HA0ulOg= X-Complaints-To: Complaints to abuse@clear.net.nz X-DMCA-Complaints-To: Complaints to abuse@clear.net.nz X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.1 Xref: archiver1.google.com comp.lang.ada:2915 X-Received-Date: Tue, 25 Nov 2003 05:06:55 EST (news1.east.cox.net) Date: 2003-11-25T23:06:52+13:00 List-Id: On Fri, 14 Nov 2003 11:16:22 +0100, Dmitry A. Kazakov wrote: >On Fri, 14 Nov 2003 10:44:47 +0100, Vinzent 'Gadget' Hoefler wrote: ... >>>On Fri, 14 Nov 2003 10:04:02 +1300 >>>Craig Carey wrote: ... >>>> Ada 95 could be enhanced so that specified record fields could be >>>> read-only. >> >>BTW, this is a neat idea. OTOH, for this approach to be practical >>someone *must* have write access. > >1. Not always. We already have constant "record" fields in Ada. They >are called discriminants. >2. Constructor ... 1. Perhaps Mr Kazakov would priovide more details about the "Not Always" comment.It could be the default assignment of a pointer pointing into the interior of the same record. 2. Since Ada 95 lacks read-only fields, so would the "We" of the message I reply to. A solution is to replace field "X : Integer" with X : Integer_Access_Constant_Ptr XA : Private_Type_Supposedly_Integer; Maybe the record has to the tagged to get the pointer initialized. It is awkward inide of the package and outside too. All external statements like this "if X.Denom /= Y.Denom .." would be changed to "if X.Denom.all /= Y.Denom.all". A better solution might be to make every field be read-only, and then remove read-only statuse from fields only by one. The package is rewritten so that its procedures expect an "access constant" pointer to the record, instead of record. Data_ZZZ : aliased P.D_Priv_Rec; -- Real record, don't use Data : constant P.D_Type := Data_ZZZX'Access; -- 100% R/O To write to a single field, dereference a pointer function. E.g.: Ptr_Field_Bigness (X).all := (3, 2); ObjectAda compiler easily finds that discriminants are not the hoped for read-only feature: ------------- type num is record Num, Den : Integer; end record; type Arbitrary (Pool_Const : Num) is -- <-- Invalid Ada record Arb : Num; end record; -- ObjectAda 7.2.2 says "Error: LRM:3.7(9), the subtype of a -- discriminant must be a discrete or access subtype" -- [or defined using "access subtype_mark"]. ------------- Discrimannts are not actually read-only since they don't need to be supplied when the variable is declared but can be changed simply afterwards. It does not sound like something that is read-only. Craig Carey Ada mailing lists: http://www.ijs.co.nz/ada_95.htm