Nick Sabalausky wrote:
"Pelle Månsson" wrote in message
news:hcaaro$15e...@digitalmars.com...
I think foreach should be consistent with opIn, that is,
if (foo in aa) { //it is in the aa.
foreach (f; aa) { // loop over each item in the aa
//I expect foo to show up in here, since it is "in"
"bearophile" wrote in message
news:hca087$dv...@digitalmars.com...
> Andrei Alexandrescu:
>
>> That is debatable as it would make the same code do different things for
>> e.g. vectors and sparse vectors.
>
> Iterating on the keys is more useful, in real-world programs.
>
If you mean because it's
"Pelle Månsson" wrote in message
news:hcaaro$15e...@digitalmars.com...
> I think foreach should be consistent with opIn, that is,
> if (foo in aa) { //it is in the aa.
> foreach (f; aa) { // loop over each item in the aa
> //I expect foo to show up in here, since it is "in" the aa.
> }
>
Simen Kjaeraas, el 29 de octubre a las 22:06 me escribiste:
> bearophile wrote:
>
> >In nothrow functions you can use a different method, like
> >"discard" (or a similar name less intuitive than remove), that's
> >like remove, but it doesn't throw and just returns false when the
> >key was absent
bearophile wrote:
In nothrow functions you can use a different method, like "discard" (or
a similar name less intuitive than remove), that's like remove, but it
doesn't throw and just returns false when the key was absent.
The idea is to use the safer method by default and the less safe one
KennyTM~:
> (Moreover, having .remove() to throw means you can't delete any
> dictionary items in nothrow functions. Sure you can silent it with
> try/catch but that's expensive.)
In nothrow functions you can use a different method, like "discard" (or a
similar name less intuitive than remove)
Andrei Alexandrescu, el 29 de octubre a las 13:26 me escribiste:
> Leandro Lucarella wrote:
> >Andrei Alexandrescu, el 29 de octubre a las 12:33 me escribiste:
> >>Bill Baxter wrote:
> I think bool remove(key) is better than all other designs suggested so
> far.
> >>>I agree with the folks
Bill Baxter, el 29 de octubre a las 11:31 me escribiste:
> On Thu, Oct 29, 2009 at 11:16 AM, Leandro Lucarella wrote:
> >> that's the overwhelmingly common case though, and if it's, say,
> >> about 50/50, then it's much more sensible to have a non-throwing
> >> primitive than a throwing one. And i
Andrei Alexandrescu wrote:
> rmcguire wrote:
>> Wouldn't opIn be more useful if it returned a range starting with
>> the element that was found?
>
> Thought about that, but it's hard to justify. Items aren't sorted in any
> particular order, so you'd get pretty much a random bunch of stuff.
>
KennyTM~, el 30 de octubre a las 02:55 me escribiste:
> On Oct 30, 09 01:14, bearophile wrote:
> >KennyTM~:
> >
> >>Um what? aa["theKey"] = 1 doesn't fail, why should aa.remove("theKey")
> >>be special?
> >
> >That's a different situation.
> >You probably meant to say: If aa["theKey"]++; doesn't fa
rmcguire wrote:
Wouldn't opIn be more useful if it returned a range starting with
the element that was found?
Thought about that, but it's hard to justify. Items aren't sorted in any
particular order, so you'd get pretty much a random bunch of stuff.
Andrei
On Oct 30, 09 01:14, bearophile wrote:
KennyTM~:
Um what? aa["theKey"] = 1 doesn't fail, why should aa.remove("theKey")
be special?
That's a different situation.
You probably meant to say: If aa["theKey"]++; doesn't fail, why should
aa.remove("theKey") be special?
void discard(K,V)(ref V[
Andrei Alexandrescu wrote:
> Denis Koroskin wrote:
>> On Wed, 28 Oct 2009 17:22:00 +0300, Andrei Alexandrescu
>> wrote:
>>
>>> Walter has magically converted his work on T[new] into work on making
>>> associative arrays true templates defined in druntime and not
>>> considered very special
On Thu, Oct 29, 2009 at 11:16 AM, Leandro Lucarella wrote:
> Andrei Alexandrescu, el 29 de octubre a las 12:33 me escribiste:
>> Bill Baxter wrote:
>> >>I think bool remove(key) is better than all other designs suggested so far.
>> >
>> >I agree with the folks who say it's error-prone. I can just
Leandro Lucarella wrote:
Andrei Alexandrescu, el 29 de octubre a las 12:33 me escribiste:
Bill Baxter wrote:
I think bool remove(key) is better than all other designs suggested so far.
I agree with the folks who say it's error-prone. I can just see
myself now removing a key I know is in the d
On Thu, Oct 29, 2009 at 10:33 AM, Andrei Alexandrescu
wrote:
> Bill Baxter wrote:
>>
>> On Thu, Oct 29, 2009 at 8:39 AM, Andrei Alexandrescu
>> wrote:
>>>
>>> Leandro Lucarella wrote:
Andrei Alexandrescu, el 28 de octubre a las 20:29 me escribiste:
>>>
>>> Your test looks someth
Andrei Alexandrescu, el 29 de octubre a las 12:33 me escribiste:
> Bill Baxter wrote:
> >>I think bool remove(key) is better than all other designs suggested so far.
> >
> >I agree with the folks who say it's error-prone. I can just see
> >myself now removing a key I know is in the dictionary and
Bill Baxter wrote:
On Thu, Oct 29, 2009 at 8:39 AM, Andrei Alexandrescu
wrote:
Leandro Lucarella wrote:
Andrei Alexandrescu, el 28 de octubre a las 20:29 me escribiste:
Your test looks something up and then removes it.
Andrei
Well, my extended test case looks something up, manipulates the
On Thu, Oct 29, 2009 at 9:57 AM, KennyTM~ wrote:
> On Oct 29, 09 23:59, Bill Baxter wrote:
>>
>> On Thu, Oct 29, 2009 at 8:39 AM, Andrei Alexandrescu
>> wrote:
>>>
>>> Leandro Lucarella wrote:
Andrei Alexandrescu, el 28 de octubre a las 20:29 me escribiste:
>>>
>>> Your test lo
KennyTM~:
> Um what? aa["theKey"] = 1 doesn't fail, why should aa.remove("theKey")
> be special?
That's a different situation.
You probably meant to say: If aa["theKey"]++; doesn't fail, why should
aa.remove("theKey") be special?
> void discard(K,V)(ref V[K] aa, in K key) {
>if (!aa.remov
On Oct 29, 09 23:59, Bill Baxter wrote:
On Thu, Oct 29, 2009 at 8:39 AM, Andrei Alexandrescu
wrote:
Leandro Lucarella wrote:
Andrei Alexandrescu, el 28 de octubre a las 20:29 me escribiste:
Your test looks something up and then removes it.
Andrei
Well, my extended test case looks somet
Andrei Alexandrescu Wrote:
> Two other iterations are possible: by key and by value (in those cases
> iter.front just returns a key or a value).
Well, AA already has properties keys and values and you can already iterate
over them. I think, it's ok to restrict to opApply(int delegate(ref KeyTyp
On Thu, Oct 29, 2009 at 8:39 AM, Andrei Alexandrescu
wrote:
> Leandro Lucarella wrote:
>>
>> Andrei Alexandrescu, el 28 de octubre a las 20:29 me escribiste:
>
> Your test looks something up and then removes it.
>
>
> Andrei
Well, my extended test case looks something
Leandro Lucarella wrote:
Andrei Alexandrescu, el 28 de octubre a las 20:29 me escribiste:
Your test looks something up and then removes it.
Andrei
Well, my extended test case looks something up, manipulates the
found value, and then possibly removes it.
Ok, I understand your points, thanks f
Andrei Alexandrescu, el 28 de octubre a las 20:29 me escribiste:
> >>Your test looks something up and then removes it.
> >>
> >>
> >>Andrei
> >
> >Well, my extended test case looks something up, manipulates the
> >found value, and then possibly removes it.
>
> Ok, I understand your points, thanks
bearophile:
> Pelle Månsson:
> > I agree with this. I usually want exceptions.
>
> A problem with this is that currently exceptions are very slow in D compiled
> with DMD (something like up to 11 times slower than Java exceptions, about
> 2-4 times slower than Python exceptions. I have a benchm
Pelle Månsson:
> I agree with this. I usually want exceptions.
A problem with this is that currently exceptions are very slow in D compiled
with DMD (something like up to 11 times slower than Java exceptions, about 2-4
times slower than Python exceptions. I have a benchmark for this on my site).
On Wed, 28 Oct 2009 10:22:00 -0400, Andrei Alexandrescu
wrote:
Walter has magically converted his work on T[new] into work on making
associative arrays true templates defined in druntime and not considered
very special by the compiler.
This is very exciting because it opens up or simplif
On Wed, 28 Oct 2009 20:08:34 -0400, Andrei Alexandrescu
wrote:
Denis Koroskin wrote:
On Wed, 28 Oct 2009 23:18:08 +0300, Andrei Alexandrescu
wrote:
I'd also like you to add a few things in an AA interface.
First, opIn should not return a pointer to Value, but a pointer to a
pair of K
bearophile wrote:
Andrei Alexandrescu:
I'll make aa.remove(key) always work and return a bool that tells you
whether there was a mapping or not.
I think that's a small design mistake. In a high level language you want things
to not fail silently. You want them to fail in an explicit way beca
Andrei Alexandrescu:
> I'll make aa.remove(key) always work and return a bool that tells you
> whether there was a mapping or not.
I think that's a small design mistake. In a high level language you want things
to not fail silently. You want them to fail in an explicit way because
programmers
Denis Koroskin wrote:
On Thu, 29 Oct 2009 03:08:34 +0300, Andrei Alexandrescu
wrote:
Denis Koroskin wrote:
On Wed, 28 Oct 2009 23:18:08 +0300, Andrei Alexandrescu
wrote:
I'd also like you to add a few things in an AA interface.
First, opIn should not return a pointer to Value, but a poi
On Thu, 29 Oct 2009 03:08:34 +0300, Andrei Alexandrescu
wrote:
Denis Koroskin wrote:
On Wed, 28 Oct 2009 23:18:08 +0300, Andrei Alexandrescu
wrote:
I'd also like you to add a few things in an AA interface.
First, opIn should not return a pointer to Value, but a pointer to a
pair of K
Denis Koroskin wrote:
On Wed, 28 Oct 2009 23:18:08 +0300, Andrei Alexandrescu
wrote:
I'd also like you to add a few things in an AA interface.
First, opIn should not return a pointer to Value, but a pointer to a
pair of Key and Value, if possible (i.e. if this change won't
sacrifice perfor
Lars T. Kyllingstad wrote:
Andrei Alexandrescu wrote:
dsimcha wrote:
== Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s
article
Walter has magically converted his work on T[new] into work on making
associative arrays true templates defined in druntime and not
considered
very
Andrei Alexandrescu wrote:
dsimcha wrote:
== Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s
article
Walter has magically converted his work on T[new] into work on making
associative arrays true templates defined in druntime and not considered
very special by the compiler.
This
Lars T. Kyllingstad wrote:
Pelle Månsson wrote:
Lars T. Kyllingstad wrote:
Pelle Månsson wrote:
Andrei Alexandrescu wrote:
Pelle Månsson wrote:
Also, foreach with a single variable should default to keys, in my
opinion.
That is debatable as it would make the same code do different
things
On Wed, 28 Oct 2009 23:18:08 +0300, Andrei Alexandrescu
wrote:
I'd also like you to add a few things in an AA interface.
First, opIn should not return a pointer to Value, but a pointer to a
pair of Key and Value, if possible (i.e. if this change won't sacrifice
performance).
I'm coy ab
Pelle Månsson wrote:
Lars T. Kyllingstad wrote:
Pelle Månsson wrote:
Andrei Alexandrescu wrote:
Pelle Månsson wrote:
Also, foreach with a single variable should default to keys, in my
opinion.
That is debatable as it would make the same code do different things
for e.g. vectors and sparse
Denis Koroskin wrote:
On Wed, 28 Oct 2009 17:22:00 +0300, Andrei Alexandrescu
wrote:
Walter has magically converted his work on T[new] into work on making
associative arrays true templates defined in druntime and not
considered very special by the compiler.
Wow, this is outstanding! (I h
Lars T. Kyllingstad wrote:
Pelle Månsson wrote:
Andrei Alexandrescu wrote:
Pelle Månsson wrote:
Also, foreach with a single variable should default to keys, in my
opinion.
That is debatable as it would make the same code do different things
for e.g. vectors and sparse vectors.
Andrei
D
Robert Jacques wrote:
On Wed, 28 Oct 2009 15:06:34 -0400, Denis Koroskin <2kor...@gmail.com>
wrote:
On Wed, 28 Oct 2009 17:22:00 +0300, Andrei Alexandrescu
wrote:
Walter has magically converted his work on T[new] into work on making
associative arrays true templates defined in druntime and
Denis Koroskin wrote:
On Wed, 28 Oct 2009 17:22:00 +0300, Andrei Alexandrescu
wrote:
Walter has magically converted his work on T[new] into work on making
associative arrays true templates defined in druntime and not
considered very special by the compiler.
Wow, this is outstanding! (I h
On Wed, 28 Oct 2009 22:24:46 +0300, Robert Jacques
wrote:
On Wed, 28 Oct 2009 15:06:34 -0400, Denis Koroskin <2kor...@gmail.com>
wrote:
On Wed, 28 Oct 2009 17:22:00 +0300, Andrei Alexandrescu
wrote:
Walter has magically converted his work on T[new] into work on making
associative ar
On Wed, 28 Oct 2009 15:06:34 -0400, Denis Koroskin <2kor...@gmail.com>
wrote:
On Wed, 28 Oct 2009 17:22:00 +0300, Andrei Alexandrescu
wrote:
Walter has magically converted his work on T[new] into work on making
associative arrays true templates defined in druntime and not
considered ve
On Wed, 28 Oct 2009 17:22:00 +0300, Andrei Alexandrescu
wrote:
Walter has magically converted his work on T[new] into work on making
associative arrays true templates defined in druntime and not considered
very special by the compiler.
Wow, this is outstanding! (I hope it didn't have a
Andrei Alexandrescu:
> That is debatable as it would make the same code do different things for
> e.g. vectors and sparse vectors.
Iterating on the keys is more useful, in real-world programs.
Regarding the names:
- "keys", "values" return lazy iterators. "keys" returns a set-like object that
Pelle Månsson wrote:
Andrei Alexandrescu wrote:
Pelle Månsson wrote:
Also, foreach with a single variable should default to keys, in my
opinion.
That is debatable as it would make the same code do different things
for e.g. vectors and sparse vectors.
Andrei
Debatable indeed, but I find
yigal chripun wrote:
Andrei Alexandrescu Wrote:
Walter has magically converted his work on T[new] into work on making
associative arrays true templates defined in druntime and not considered
very special by the compiler.
This is very exciting because it opens up or simplifies a number of
po
Pelle Månsson, el 28 de octubre a las 15:48 me escribiste:
> Andrei Alexandrescu wrote:
> >Walter has magically converted his work on T[new] into work on
> >making associative arrays true templates defined in druntime and
> >not considered very special by the compiler.
> >
> >This is very exciting
Andrei Alexandrescu Wrote:
> Walter has magically converted his work on T[new] into work on making
> associative arrays true templates defined in druntime and not considered
> very special by the compiler.
>
> This is very exciting because it opens up or simplifies a number of
> possibilities.
dsimcha wrote:
== Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s article
Walter has magically converted his work on T[new] into work on making
associative arrays true templates defined in druntime and not considered
very special by the compiler.
This is very exciting because it
On Wed, 28 Oct 2009 09:22:00 -0500, Andrei Alexandrescu
wrote:
>Walter has magically converted his work on T[new] into work on making
>associative arrays true templates defined in druntime and not considered
>very special by the compiler.
>
>This is very exciting because it opens up or simplifi
== Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s article
> Walter has magically converted his work on T[new] into work on making
> associative arrays true templates defined in druntime and not considered
> very special by the compiler.
> This is very exciting because it opens up
Andrei Alexandrescu wrote:
Pelle Månsson wrote:
Andrei Alexandrescu wrote:
Walter has magically converted his work on T[new] into work on making
associative arrays true templates defined in druntime and not
considered very special by the compiler.
This is very exciting because it opens up or
Andrei Alexandrescu Wrote:
> Walter has magically converted his work on T[new] into work on making
> associative arrays true templates defined in druntime and not considered
> very special by the compiler.
>
> This is very exciting because it opens up or simplifies a number of
> possibilities.
Pelle Månsson wrote:
Andrei Alexandrescu wrote:
Walter has magically converted his work on T[new] into work on making
associative arrays true templates defined in druntime and not
considered very special by the compiler.
This is very exciting because it opens up or simplifies a number of
pos
Andrei Alexandrescu wrote:
Walter has magically converted his work on T[new] into work on making
associative arrays true templates defined in druntime and not considered
very special by the compiler.
This is very exciting because it opens up or simplifies a number of
possibilities. One is tha
Walter has magically converted his work on T[new] into work on making
associative arrays true templates defined in druntime and not considered
very special by the compiler.
This is very exciting because it opens up or simplifies a number of
possibilities. One is that of implementing true itera
59 matches
Mail list logo