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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.236.101.148 with SMTP id b20mr2981447yhg.46.1408033773794; Thu, 14 Aug 2014 09:29:33 -0700 (PDT) X-Received: by 10.51.17.69 with SMTP id gc5mr369992igd.0.1408033773532; Thu, 14 Aug 2014 09:29:33 -0700 (PDT) Path: backlog1.nntp.dca1.giganews.com!buffer1.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!v10no7081052qac.1!news-out.google.com!px9ni620igc.0!nntp.google.com!h18no13072519igc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 14 Aug 2014 09:29:32 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=KSa2aQoAAACOxnC0usBJYX8NE3x3a1Xq NNTP-Posting-Host: 66.126.103.122 References: <16a948da-f477-45a2-a6dd-be1d8c19f1d4@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Intermixing two tagged types From: Adam Beneschan Injection-Date: Thu, 14 Aug 2014 16:29:33 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: number.nntp.dca.giganews.com comp.lang.ada:188490 Date: 2014-08-14T09:29:32-07:00 List-Id: On Thursday, August 14, 2014 9:11:02 AM UTC-7, Victor Porton wrote: > Thank you for your suggestion. However I already know this. >=20 > But working this way would be a wrong way. In the meaning of things the= =20 > entire record is controlled, not its part. So controlling a part would be= a=20 > hack, not a good way to do programming. Unfortunately, sometimes you have make compromises to work around the langu= age. Anyway, if your untagged type has just *one* component that is the "entire"= record, that might be close enough to the "right" way to make you feel you= 're not using a hack--or at least you're using only a minor hack. If you g= ive the component a one-letter name like R, then it means you have to add "= R." every time you want to access a field in your record. It's a nuisance.= But it might be the least of evils. I've had to do things like this; usually it's when I have a variant record = with a discriminant with a default, like: type Value (Value_Type : Value_Classes :=3D Value_Classes'First) is rec= ord case Value_Classes is ... end case; end record; (A lot of this was written in the Ada 83 days.) The rules allow you to cha= nge the discriminant of a Value by reassigning the whole record. But you *= can't* do this if you have an "access Value" Acc; you can't change the disc= riminant of Acc.all by reassigning it. You *can*, however, wrap Value in a= nother record (with one component V), and if you have an "access Value_Wrap= per" Wrapper_Acc, you can change the discriminant of Wrapper_Acc.V.all. An= noying, but it works. There were reasons why this rule is in the language,= but I wish it had provided a way to let me allocate a "new Value" whose di= scriminant can be changed. Providing too many options, however, can muddy = the syntax of the language, so it's a trade-off between adding language rul= es that require annoying workarounds like this, and providing so many featu= res that it drives everybody crazy (language designers, implementors, users= ) and increases the chance of mistakes or unsafe features creeping into the= language semantics. Bottom line is: there is no Holy Grail of a perfect language, and if you wa= it for a language that never requires you to do things a "wrong" way, you w= ill be waiting a very, very long time. We'll probably solve the halting pr= oblem before we can produce a language like that. :) -- Adam