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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Type extension and discriminants Date: Sun, 12 Oct 2014 08:51:32 +0200 Organization: cbb software GmbH Message-ID: References: <8d6fe2a6-a8fa-441f-8b35-fc5a744359fb@googlegroups.com> <1m1grtt4tjy6m$.2tgdf5cel9tn$.dlg@40tude.net> <1d5e857d-1c16-40be-9f4d-fba44ce22e42@googlegroups.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: ZB2Fb2q1fa4xpMpNKFqV6Q.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:22375 Date: 2014-10-12T08:51:32+02:00 List-Id: On Sat, 11 Oct 2014 14:09:48 -0700 (PDT), sbelmont700@gmail.com wrote: [...] > Obviously this a case-by-case sort of thing, but this is certainly a > pattern any purportedly OOP language needs to support. No. The language should support constructors, not this nonsense (I mean returning limited objects rubbish). >> In short, limited return (constructing function) and limited aggregate are >> not suitable for construction of parent objects which private discriminants >> and components. > > +1(000). This is especially aggravating, because Ada's access > discriminants and pass-by-reference semantics are so totally superior for > saving references to other objects without having to resort to the heap. Well, access discriminants were invented as a hack, e.g. for having mix-ins instead of honest multiple inheritance or for circumvention of function's "in" parameter modes etc. An access discriminant represent a serious safety problem, in combination with dynamic accessibility checks, a deadly problem. > But the intermixing of "true" discriminated records (i.e. variant records, > where the structure actually depends on the discriminant), and "fake" > discriminated records that just use them when they need a constant always > seems to cause endless headaches. Discriminants are misused in many ways. Having an immutable (constant) record member is one of them. > I just wish I had a better idea of how > to do it, because C++ initializer lists are a syntax abomination. :'-( The language should have proper abstraction mechanisms. Ada is only halfway there. Otherwise a discriminant would be a pure type constraint which implementation would not necessarily be a record member while the type would not necessarily be a record. Ugly Ada 2012 aspects are somewhat would-be discriminants. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de