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!news4.google.com!news.germany.com!news.teledata-fn.de!noris.net!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> <1177373706.552914.71270@q75g2000hsh.googlegroups.com> <1ccueevyp8oba.11c8wwyujtw1o$.dlg@40tude.net> <1177432057.705889.229690@n35g2000prd.googlegroups.com> Date: Tue, 24 Apr 2007 22:19:30 +0200 Message-ID: <1op3ml5q11aa$.vg0a2lyc9dpv$.dlg@40tude.net> NNTP-Posting-Date: 24 Apr 2007 22:19:23 CEST NNTP-Posting-Host: a84109d4.newsspool3.arcor-online.net X-Trace: DXC=R_d\=ZXhf?c[F<50eo:0knMcF=Q^Z^V3h4Fo<]lROoRaFl8W>\BH3YbYd@R On 24 Apr 2007 09:27:37 -0700, Adam Beneschan wrote: > On Apr 24, 3:43 am, "Dmitry A. Kazakov" > wrote: > >>>>> 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. >> >>> OK, I've got it. >> >>> function "=" (X, Y : GUI_Boolean) return Boolean is >>> begin >>> if not X.Defined or else not Y.Defined then >>> raise Constraint_Error; >>> else >>> return X = Y; >>> end if; >>> end "="; >> >>> Is that how you thought this user-defined "=" would be written? >> >> Yup, the predefined "=" should be renamed first. > > So a user-defined "=" that causes a stack overflow due to infinite > recursion doesn't bother you? > You still don't see the issue, do you? Which issue? As I said if you want to get at the predefined "=" you have to rename it first: type GUI_Boolean (Defined : Boolean := True) is (True, False); function Equal (Left, Right : GUI_Boolean) return Boolean renames "="; function "=" (Left, Right : GUI_Boolean) return Boolean; function "=" (Left, Right : GUI_Boolean) return Boolean is begin if not (X.Defined and then Y.Defined) then raise Constraint_Error; else return Equal (X, Y); end if; end "="; >> I don't see any problems with generation of a predefined "=" and literals >> (True, False). [True is a literal of the type GUI_Boolean, with all >> consequences of that.] > > If True has type GUI_Boolean, then it must have a "Defined" > discriminant. It does (the GUI_Boolean returned by the literal has it). > What is True.Defined? How does the programmer indicate > what it would be? (And if you say that True.Defined is "true" because > "true" is a defined value, then you still don't get it---the Ada > language isn't going to know that, and you're going to need a way to > tell it that.) True is a literal. The rule is quite simple. If the literal is not abstract and not overridden then its discriminants are defined by the corresponding default expressions. If absence of aggregates was your concern, that is not a problem either: function Undefined return GUI_Boolean is Result : GUI_Boolean (False); begin return Result; end Undefined: -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de