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,9c9db81a63ddf1fe X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!q36g2000yqn.googlegroups.com!not-for-mail From: Dan Newsgroups: comp.lang.ada Subject: Re: extended membership tests Date: Thu, 31 Mar 2011 23:33:11 -0700 (PDT) Organization: http://groups.google.com Message-ID: <9e379bf0-ade3-4694-83d3-60d99f54bdf5@q36g2000yqn.googlegroups.com> References: <7dc23d58-4a48-4444-90cd-7f9786b19aad@i14g2000yqe.googlegroups.com> <5ab2b5ee-d08e-4e5e-93a7-808636f3cfa0@p16g2000yqb.googlegroups.com> NNTP-Posting-Host: 72.211.206.238 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1301639591 4349 127.0.0.1 (1 Apr 2011 06:33:11 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 1 Apr 2011 06:33:11 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: q36g2000yqn.googlegroups.com; posting-host=72.211.206.238; posting-account=mj1SqQkAAAC-ugS7xMajTlZAhqdqcRbD User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; eSobiSubscriber 2.0.4.16; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C; AskTB5.2),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:19619 Date: 2011-03-31T23:33:11-07:00 List-Id: On Mar 31, 10:14=A0pm, AdaMagica wrote: > On 31 Mrz., 16:33, Robert A Duff wrote: > > > For extra credit, what happens if we replace b2 with: > > > =A0 =A0 b3: boolean :=3D int_sets.to_set(new_item =3D> x) > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 in int_sets.to_set(new_item =3D> x) > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 or int_sets.to_set(new_item =3D> y); > > OK, I'll try. We should write this as > > =A0 =A0b3: boolean :=3D > =A0 =A0int_sets.to_set(new_item =3D> x) in > =A0 =A0 =A0 int_sets.to_set(new_item =3D> x) or int_sets.to_set(new_item = =3D> > y); > > So the right-hand side is a choice_expression of the form > simple_expression or simple_expression. > So if there isn't an or operator for sets (I don't know, I didn't > check the set container), it's illegal. > If there is one, it's a set (presumably the union) and it's the > tested_set. > The lhs is a simple_expression which is tagged (I presume sets are > tagged) which must resolve to a type convertible to the tested type, > which it is. > Now we have an individual membership test lhs in rhs. > The simple expression (lhs) is not equal to the value of the > membership_choice (rhs). So the membership test returns False. > > =A0 =A0int_sets.to_set(new_item =3D> x) in > =A0 =A0 =A0 int_sets.to_set(new_item =3D> x) | int_sets.to_set(new_item = =3D> y); > > would return True. > > This doesn't seem very intuitive to me. (Provided that my reading of > the RM is correct.) I think it's fair to say that the proposed definition of the membership operator to sometimes mean "=3D" is counter-intuitive to just about everyone, and is an unintended consequence of the new syntax rules which were designed for more complicated expressions, such as x in 2 | 5..10. I think it's also somewhat likely that the language will be extended at some point to allow the membership operator to apply to the Set containers, or actually any "iterable" type. AI05-0139-2 proposes to integrate iterable types with for loops, and it would seem to be a natural extension to similarly integrate them with membership tests. But if that is done, the possible interpretation of X in Y as an equality test would be even more confusing than it is now (as the b3 example suggests). Yannick suggested making X in Y illegal, when X and Y have the same type, to avoid the confusion. I agree with that suggestion. -- Dan