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,2a3157e5254b8223 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!nuzba.szn.dk!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Array slices and types Date: Thu, 21 Aug 2008 23:30:47 -0500 Organization: Jacob's private Usenet server Message-ID: References: <5886ab95-8744-4b72-b911-e4cb8889c7e7@d1g2000hsg.googlegroups.com> <1k5uib98w8fgw.bno6vggps1p3.dlg@40tude.net> <48ac6750$0$23587$4f793bc4@news.tdc.fi> <48acfbe8$0$23588$4f793bc4@news.tdc.fi> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: jacob-sparre.dk 1219379622 23715 69.95.181.76 (22 Aug 2008 04:33:42 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Fri, 22 Aug 2008 04:33:42 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5512 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512 Xref: g2news2.google.com comp.lang.ada:7477 Date: 2008-08-21T23:30:47-05:00 List-Id: "Adam Beneschan" wrote in message news:fc112b42-285c-4ed5-ae78-34be4e60f6df@i20g2000prf.googlegroups.com... > On Aug 21, 1:53 am, "Dmitry A. Kazakov" > wrote: >> On Thu, 21 Aug 2008 08:26:26 +0300, Niklas Holsti wrote: >> > But doesn't this example show that it would be useful to have 'Base >> > also for array types? >> >> For any type, actually. >> >> Consider this language design fault: >> >> procedure Initialize (X : in out S) is >> begin >> Initialize (T (X)); >> ... -- My stuff >> end Initialize; >> >> A call to Initialize should be done automatically, but it is not. So the >> parent of S must be explicitly specified and known to all descendant. >> This >> is a really *bad* thing: >> >> package Foo is >> type S is new T with private; >> private >> type S is new Private_Decendant_Of_T with ...; >> end Foo; >> >> What would happen if Private_Decendant_Of_T overrode Initialize of T? The >> result would be an inability to publicly derive from S any new types if >> Initialize should be extended! >> >> S'Base could mend it: >> >> procedure Initialize (X : in out S) is >> begin >> (S"Base (X)).Initialize; -- Call to parent whatever it be >> ... -- My stuff >> end Initialize; > > Sorry, Dmitry, but if you'll pardon the expression, you're a little > off-base here. S'Base and S are subtypes of the same *type*. They > may be different subtypes (have different constraints), but they're > the same type. You're asking for an attribute that would give you a > different type. There may be merit in having such an attribute (I > haven't looked into it closely), but calling it 'Base would be a bad > idea. S'Parent might be better. I tried to propose such a thing for Ada 2005, but it didn't work out. There isn't necessarily a single type that is the parent, unless you break privacy. Specifically: package P is type New_Type is new Some_Base with private; procedure Some_Operation (Obj : in out New_Type; Parent : in New_Type'Parent); private type New_Type is new Some_Derived with record ... end P; In this case, what does New_Type'Parent give you in the body? We'd want it to resolve to Some_Derived. But a client of P can't see the full declaration (and shouldn't be able to depend on it), and thus P.New_Type'Parent would have to resolve to Some_Base. So far, we can live with this. But now consider the completion to Some_Operation: the body would use the same parameter types in order to conform, but the *meaning* of the second parameter would be different to clients and the body. Oops. One could ban using this attribute in such specs, but that looks like a nasty wart (as bad as the original one). Thus, we didn't get a 'Parent attribute. > Niklas is asking for S'Base to be the unconstrained array subtype of > the (possibly constrained) array subtype S. It would still fit into > the definition of 'Base (3.5(15)). I'm not sure why this wasn't > defined for array subtypes, or for any other type that could have > discriminants; offhand I don't see how this would cause any problems. It does cause problems, and they're pretty severe as I recall. After all, Ada 83 allowed 'Base on everything (but only as a prefix of another attribute). That was removed in Ada 95 because of problems. But I can't remember what they were precisely. Sorry about that. Randy.