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 X-Google-Thread: 103376,1a52c822fc0dbb23 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Rational for not making cursor tagged in Containers Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1176998738.656903.141250@q75g2000hsh.googlegroups.com> <1177010938.200523.325290@p77g2000hsh.googlegroups.com> <1a8y2vakorfhx.225uqh4hifpd$.dlg@40tude.net> <1xmzi7newnilp.23m3zze8h9yi.dlg@40tude.net> <1177066583.5876.30.camel@localhost.localdomain> <1177080147.5876.87.camel@localhost.localdomain> <1q1kx2jlcvnuj.ck0711mj4few$.dlg@40tude.net> <1177097829.26685.36.camel@localhost.localdomain> <95wmj9goo6wc$.13f1j4dnadwws$.dlg@40tude.net> <1177349886.343834.295210@q75g2000hsh.googlegroups.com> Date: Mon, 23 Apr 2007 21:18:30 +0200 Message-ID: NNTP-Posting-Date: 23 Apr 2007 21:18:26 CEST NNTP-Posting-Host: b2d345d8.newsspool3.arcor-online.net X-Trace: DXC=4>0iTn9gokRI?44J>Z[:RQMcF=Q^Z^V3X4Fo<]lROoRQFl8W>\BH3YR?P2N8WQ]`>_DNcfSJ;bb[UIRnRBaCd On 23 Apr 2007 10:38:06 -0700, Adam Beneschan wrote: > On Apr 20, 3:14 pm, "Dmitry A. Kazakov" > wrote: > >>> But please explain what use is a Boolean with discriminants. >>> I'm not sure... >> >> type GUI_Boolean (Defined : Boolean := True) is (False, True); >> >> When Defined = False, the value is rendered as blank and the user is forced >> to enter it before it closes the dialog box. > > X, Y : GUI_Boolean; > > If you say X = Y, does it compare just the values, or does it compare > the discriminants also? That depends on how equality operation were defined for the given type. In the concrete case of GUI_Boolean, the user-defined "=" would raise Constraint_Error if at least one of the discriminants is false. There will be probably another private equivalence defined for the containers of GUI_Boolean. > If it compares the discriminants, what do you write when you want to > compare just the values, without caring what the discriminants happen > to be? It is the programmer's business to define correct "=". Ada has no responsibility to generate semantically correct equality. > What does "X = True" mean? Does X.Defined have any effect on the > value of this expression? > > OK, X is a GUI_Boolean that has Defined=false. You now want to create > Y to be a GUI_Boolean that has the same value as X but Defined=true. This is semantically wrong for GUI_Boolean. An undefined value has no defined value... > How do you write that, given that Ada does not let you put a > discriminant on the left side of an assignment? How do you change Float'Fraction of a Float X keeping the value of X same? How do you change X'Length without changing the value of X? Why should I write such things? > There are lots of syntactic and semantic issues involved with sticking > a discriminant on a scalar that you probably haven't thought through. All these problems were solved for the type String. In general, the problems you have referred equally apply to attributes of values. Ada has lots of attributes of values, whether scalar or not. That never was a problem. > I agree with Randy---that way lies madness, or at the very least a > severe migraine. Thank you, but I think I'll stick to > > type My_Boolean_Value is (False, True); > type GUI_Boolean (Defined : Boolean := True) is record > Val : My_Boolean_Value; > end record; > > At least I know what I'm doing if I use this type. If X is a > GUI_Boolean, then X refers to the whole record and X.Val refers to > just the value. Nice, simple, easy to understand. To have a public discriminant has nothing to do with being implemented as a record. And reverse. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de