Frits van Bommel, el 25 de mayo a las 12:37 me escribiste:
> Stewart Gordon wrote:
> >Jason House wrote:
> >
> >>Method 1:
> >>
> >>if (x !in y)
> >> foo();
> >>else{
> >> auto z = x in y;
> >> bar(z);
> >>}
> >>
> >>Method 2:
> >>
> >>auto z = x in y;
> >>if (z is null)
> >> foo;
> >>else
> >>
Stewart Gordon wrote:
Jason House wrote:
Method 1:
if (x !in y)
foo();
else{
auto z = x in y;
bar(z);
}
Method 2:
auto z = x in y;
if (z is null)
foo;
else
bar(z);
Method 1 essentially calls in twice while method 2 calls in once.
But there's no requirement to look it up after f
Jason House wrote:
Method 1:
if (x !in y)
foo();
else{
auto z = x in y;
bar(z);
}
Method 2:
auto z = x in y;
if (z is null)
foo;
else
bar(z);
Method 1 essentially calls in twice while method 2 calls in once.
But there's no requirement to look it up after finding out whether it's
Jason House:
> Method 1 essentially calls in twice while method 2 calls in once.
Sometimes I just want to know if something isn't present.
Having !in doesn't prevent me from writing and using x = y in aa; when I want
it.
> PS: Please don't assume that I'm advocating
Stewart Gordon Wrote:
> Jason House wrote:
>
> > That is unfortunately a rather sticky point. The in operator does not
> > return bool. I think the lack of !in is to encourage writing of efficient
> > code. I'm not really sure though.
>
> How, exa
Jason House wrote:
That is unfortunately a rather sticky point. The in operator does not
return bool. I think the lack of !in is to encourage writing of efficient
code. I'm not really sure though.
How, exactly, does not having !in make code efficient?
Stewart.
Jeremie Pelletier wrote:
Why is there no !in operator just like there is a !is operator? Is it
because this expression evaluates to a pointer to the found element?
Of course not. This compiles:
void main() {
char* abc;
assert (!abc);
}
so why shouldn't !in?
Stewart.
Jeremie Pelletier wrote:
> Why is there no !in operator just like there is a !is operator?
> Is it because this expression evaluates to a pointer to the found element?
> Even so, it would make asserts much easier to write.
http://dsource.org/projects/scrapple/browser/trunk/tools/too
Jason House:
> The in operator does not
> return bool. I think the lack of !in is to encourage writing of efficient
> code. I'm not really sure though.
Lot of time ago I have said I'd like !in, I'm waiting for it still.
Bye,
bearophile
Jeremie Pelletier wrote:
> Why is there no !in operator just like there is a !is operator?
> Is it because this expression evaluates to a pointer to the found element?
> Even so, it would make asserts much easier to write.
That is unfortunately a rather sticky point. The in operator
Why is there no !in operator just like there is a !is operator?
Is it because this expression evaluates to a pointer to the found element? Even
so, it would make asserts much easier to write.
11 matches
Mail list logo