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-Thread: 103376,ec21c3c7cdc7ff3e X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns14feed!worldnet.att.net!attbi_s22.POSTED!53ab2750!not-for-mail From: "Jeffrey R. Carter" Organization: jrcarter at acm dot org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060130 SeaMonkey/1.0 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: private types References: <1142279908.327131.230200@j52g2000cwj.googlegroups.com> <1FqVf.641025$084.20945@attbi_s22> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 12.214.35.215 X-Complaints-To: abuse@mchsi.com X-Trace: attbi_s22 1143402094 12.214.35.215 (Sun, 26 Mar 2006 19:41:34 GMT) NNTP-Posting-Date: Sun, 26 Mar 2006 19:41:34 GMT Date: Sun, 26 Mar 2006 19:41:34 GMT Xref: g2news1.google.com comp.lang.ada:3637 Date: 2006-03-26T19:41:34+00:00 List-Id: Robert A Duff wrote: > > An uninit var should be considered a bug, whether it's access or > integer. I see no fundamental difference, here. Defaulting to null > hides this bug. This only holds true for types that don't have meaningful default initial values. I've written lots of types for which an uninitialized variable of the type is perfectly reasonable, and even the expected behavior. Usually they're defined as "[limited] private". I don't expect users of a data structure to have to make a special initialization call to be able to use the structure. Whether the default initial value for access types is a good choice is not something I'm debating. I'm simply saying that default initial values are not a bad thing for ADTs, an access type is closer to an ADT than to a scalar type, and using the same criteria for both doesn't compute. > Yes, but my claim is that that's a poorly designed abstraction. > In most cases, null is just a tripping hazard. > The programmer should have the choice -- access type without > any special value, access type with a special value that doesn't > designate anything, access type with _two_ special values, ... That may be, but because it's an abstraction, it's not similar to scalar types, and so arguments that apply to scalar types don't necessarily apply. > Note that when I declare a private type, I choose whether it should have > "special" values, and what they mean. And I choose whether a special > value is used as a default. I can choose to raise an exception if > clients look at an uninit var. I can choose to prevent uninit > vars statically, using (<>) discriminants. Access types are like a private type. The only difference is that access types are part of the core language, and don't carry all the extra syntax that defining them as an explicit private type would add. Ichbiah and company chose that the abstraction called access types should have a "special" value, and what it means. They chose that a special value is used as a default. They chose to raise an exception if clients apply certain operations to an uninitialized variable. They may not be the choices you would make for this abstraction, but your choices may not be what others would choose, also. -- Jeff Carter "My name is Jim, but most people call me ... Jim." Blazing Saddles 39