comp.lang.ada
 help / color / mirror / Atom feed
From: Dan <dan@irvine.com>
Subject: Re: extended membership tests
Date: Thu, 31 Mar 2011 23:33:11 -0700 (PDT)
Date: 2011-03-31T23:33:11-07:00	[thread overview]
Message-ID: <9e379bf0-ade3-4694-83d3-60d99f54bdf5@q36g2000yqn.googlegroups.com> (raw)
In-Reply-To: 5ab2b5ee-d08e-4e5e-93a7-808636f3cfa0@p16g2000yqb.googlegroups.com

On Mar 31, 10:14 pm, AdaMagica <christ-usch.gr...@t-online.de> wrote:
> On 31 Mrz., 16:33, Robert A Duff <bobd...@shell01.TheWorld.com> wrote:
>
> > For extra credit, what happens if we replace b2 with:
>
> >     b3: boolean := int_sets.to_set(new_item => x)
> >                 in int_sets.to_set(new_item => x)
> >                 or int_sets.to_set(new_item => y);
>
> OK, I'll try. We should write this as
>
>    b3: boolean :=
>    int_sets.to_set(new_item => x) in
>       int_sets.to_set(new_item => x) or int_sets.to_set(new_item =>
> 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.
>
>    int_sets.to_set(new_item => x) in
>       int_sets.to_set(new_item => x) | int_sets.to_set(new_item => 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 "=" 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






  reply	other threads:[~2011-04-01  6:33 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-31  7:04 extended membership tests Dan
2011-03-31  7:34 ` AdaMagica
2011-03-31  7:55   ` Dan
2011-03-31  7:58     ` Dan
2011-03-31  8:05 ` Ludovic Brenta
2011-03-31  9:28 ` AdaMagica
2011-03-31 14:33 ` Robert A Duff
2011-03-31 16:28   ` extended membership tests (branch) Georg Bauhaus
2011-03-31 17:58     ` Robert A Duff
2011-03-31 18:54     ` Adam Beneschan
2011-03-31 21:08       ` Georg Bauhaus
2011-03-31 21:10       ` Randy Brukardt
2011-04-01  5:14   ` extended membership tests AdaMagica
2011-04-01  6:33     ` Dan [this message]
2011-04-01  7:03       ` AdaMagica
2011-04-01  9:56         ` stefan-lucks
2011-04-01 15:11         ` Adam Beneschan
2011-04-02  1:22         ` Randy Brukardt
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox