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,ed4a5cc4016f9101 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!grolier!oleane.net!oleane!news.ecp.fr!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Default value for a record component Date: Tue, 24 Jul 2007 14:12:46 -0500 Organization: Jacob's private Usenet server Message-ID: References: <1185052757.500324.16860@22g2000hsm.googlegroups.com> <1185270857.459100.34770@q75g2000hsh.googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: jacob-sparre.dk 1185304226 21182 69.95.181.76 (24 Jul 2007 19:10:26 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Tue, 24 Jul 2007 19:10:26 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1807 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1896 Xref: g2news2.google.com comp.lang.ada:1131 Date: 2007-07-24T14:12:46-05:00 List-Id: "Maciej Sobczak" wrote in message news:1185270857.459100.34770@q75g2000hsh.googlegroups.com... > On 24 Lip, 03:27, "Randy Brukardt" wrote: > > > This is a rather stupid question, especially given the C++ example that you > > give later. The closest analog to a C++ class in Ada is a controlled type. > > What is the analog of C++ struct with a constructor, then? A function is a constructor for Ada; declare an appropriate function and use it. > > Hinestly, I don't see any sane reason for being unwilling to use a > > controlled type here. > > Honestly, me neither. The question is really about the language design > and its ability to express orthogonal concepts. For me field > visibility and its initialization are orthogonal. Well, should be. Everything in Ada is inter-related; often in ways that are not obvious. I learned this the hard way when we were trying to subset Ada in the early 1980's. It just didn't work very well because there always was something else that you needed to have a full solution. Eventually we ended up with 95% of the language, and then we might as well finish the whole thing. I realize that someone relatively new to Ada might not know this, but you cannot usefully look at single features of Ada in a vacuum. You need to use many of them... ... > > In any case, having a type that is visible rather than a private type is > > almost always a mistake. > > Can't you think about examples where it isn't? (the "almost always" > part has to be complemented by something) I know of various examples where it wasn't, but those examples are almost always motivated more by laziness (don't want to write a function call to access a component) or by missing features in the language (Dmitry's "virtual components", some way to write aggregates and literals for private types, etc.). These two reasons are really the same, because if the missing features were available, one could write an appropriate private type but still use it as if it was a visible type. The net effect is that I think that if we had a "perfect" programming language, there would never be a reason to declare a visible type, but there might be such a reason given the imperfect nature of real programming languages. (But even then, you are likely to regret it.) Randy.