digitalmars.D - Issue 1323
- bearophile (8/8) Jan 08 2011 Andrei has recently closed issue 1323, it's a small but very useful feat...
- bearophile (4/5) Jan 08 2011 Sorry, I meant:
- BlazingWhitester (8/19) Jan 08 2011 This feature was discussed before.
- bearophile (11/17) Jan 08 2011 I have to search chars in strings, substrings in strings and items in ar...
- Jonathan M Davis (11/16) Jan 08 2011 opIndex is supposed to be restricted to n log(n), I belive (the complexi...
- Daniel Gibson (9/25) Jan 08 2011 "restricted to n log(n)"? I think you meant just "log(n)"
- Jonathan M Davis (8/37) Jan 08 2011 Probably. Shamefully, if I'm not careful, I tend to mix those up if I do...
- Andrei Alexandrescu (5/38) Jan 08 2011 But the reason is rock solid. Consistency is important, but it's not
- Tomek =?ISO-8859-2?Q?Sowi=F1ski?= (8/15) Jan 09 2011 thing=20
- Mafi (7/17) Jan 09 2011 Better yet, we could implement kind of Perl6 junctions. Just let
- bearophile (4/7) Jan 09 2011 Or better, as a built in feature of arrays :-) But the asymmetry between...
- Tomek =?ISO-8859-2?Q?Sowi=F1ski?= (15/19) Jan 09 2011 mon and basic. It's like calling a library
- Peter Alexander (4/19) Jan 09 2011 What's wrong with std.algorithm.canFind?
- Tomek =?ISO-8859-2?Q?Sowi=F1ski?= (4/7) Jan 09 2011 That I didn't.. er.. find it :) Sorry for the noise.
- Tomek =?ISO-8859-2?Q?Sowi=F1ski?= (5/10) Jan 09 2011 One more thing: the overload for range in range search is missing. On th...
- bearophile (4/5) Jan 09 2011 I will have to use it, then. Thank you for all the answers.
- Robert Clipsham (31/39) Jan 08 2011 I'd be all for this, except it's inconsistent.
- Andrei Alexandrescu (3/23) Jan 08 2011 That's what I'm saying, in could work for literal arrays.
- Pelle (7/27) Jan 09 2011 No, people will not wonder about that. See also: python. Seriously
- Peter Alexander (23/34) Jan 09 2011 The inconsistency doesn't just affect readability, it's an issue of
- Andrei Alexandrescu (4/32) Jan 09 2011 I'd be glad to change canFind to contains. Vote by replying to this. We
- Daniel Gibson (3/38) Jan 09 2011 Yeah, "contains" sounds better than "canFind", so
- bearophile (4/6) Jan 09 2011 In my dlibs1 I have used isIn(), but contains() is better than canFind()...
- Simen kjaeraas (5/7) Jan 09 2011 Absolutely. canFind always sounded to me like "this container supports
- Tomek =?ISO-8859-2?Q?Sowi=F1ski?= (2/4) Jan 09 2011 Like!
- Peter Alexander (2/6) Jan 09 2011 Up vote for me.
- David Nadlinger (4/6) Jan 09 2011 Changing the name to »contains« has my vote as well – »canFind« al...
- Andrej Mitrovic (10/10) Jan 09 2011 While you're at it I would really like to have a remove method in
- Andrei Alexandrescu (3/13) Jan 09 2011 An algorithm can't change the topology of the range it works on.
- Andrej Mitrovic (1/1) Jan 09 2011 s/predicate/needle
- Robert Clipsham (5/8) Jan 09 2011 ++vote;
- Andrei Alexandrescu (5/11) Jan 09 2011 I just remembered why I called it canFind: it clarifies we're talking of...
- Jonathan M Davis (13/50) Jan 09 2011 I would remind you of http://d.puremagic.com/issues/show_bug.cgi?id=4405...
Andrei has recently closed issue 1323, it's a small but very useful feature, so I suggest some public discussion: http://d.puremagic.com/issues/show_bug.cgi?id=1323 Lines like this is present thousands of time in my Python code: n in [1, 2, 3] c in "hello" "llo" in some_string Bye, bearophile
Jan 08 2011
Lines like this is present thousands of time in my Python code:Sorry, I meant: Lines like this are present thousands of times in my Python code: Bye, bearophile
Jan 08 2011
On 2011-01-09 01:20:17 +0200, bearophile said:Andrei has recently closed issue 1323, it's a small but very useful feature, so I suggest some public discussion: http://d.puremagic.com/issues/show_bug.cgi?id=1323 Lines like this is present thousands of time in my Python code: n in [1, 2, 3] c in "hello" "llo" in some_string Bye, bearophileThis feature was discussed before. If 'in' operator was overladable, users would expect it to have some known complexity. Having sintactic sugar for some operation means that it is supposed to be used widely, and using O(n) operations all over the place is not a good idea. Also, IMO, it has no real advantage, why not use std.algorithm.find instead ?
Jan 08 2011
BlazingWhitester:If 'in' operator was overladable, users would expect it to have some known complexity.Like O(n) for a linear search in an array.Having sintactic sugar for some operation means that it is supposed to be used widely, and using O(n) operations all over the place is not a good idea.I have to search chars in strings, substrings in strings and items in arrays about equally often if the syntax is built-in or it comes from one or more library functions. Well, not having a built-in array search, in D code I sometimes replace: x in [1, 5, 7] with (x == 1 || x == 5 || x == 7) that's just worse, longer, more bug-prone, less easy to read, and even a *dumb* compiler as Shedskin is able to turn the first into the second when the array is short.Also, IMO, it has no real advantage, why not use std.algorithm.find instead ?The syntax is worse, I don't like to call a function for something so common and basic. It's like calling a library function to join two strings (and find("hello", "llox") doesn't return a boolean). Bye, bearophile
Jan 08 2011
On Saturday 08 January 2011 16:19:21 bearophile wrote:BlazingWhitester:opIndex is supposed to be restricted to n log(n), I belive (the complexity necessary to access an element in a balanced, binary tree). It can have lower complexity - like O(1) - but it's not supposed to have higher complexity. opIn is effectively the operator for checking whether you can index the given container with the given key/index. It's basically doing [key] and telling you whether it's there. So, it doesn't make sense that it would have lower efficiency. This has been discussed before, and while some people would like to be able to use opIn at higher complexities, that's not the way that it's intended to be used, so we're not about to make it work that way for built-in arrays. - Jonathan M DavisIf 'in' operator was overladable, users would expect it to have some known complexity.Like O(n) for a linear search in an array.
Jan 08 2011
Am 09.01.2011 03:03, schrieb Jonathan M Davis:On Saturday 08 January 2011 16:19:21 bearophile wrote:"restricted to n log(n)"? I think you meant just "log(n)" As far as I remember the last discussion, it was considered to allow it for arrays of a constant size or with known (at compiletime) contents or something like that. But then again, that would feel kind of inconsistent (syntax is allowed for fixed size arrays but not for dynamic arrays). Cheers, - DanielBlazingWhitester:opIndex is supposed to be restricted to n log(n), I belive (the complexity necessary to access an element in a balanced, binary tree). It can have lower complexity - like O(1) - but it's not supposed to have higher complexity. opIn is effectively the operator for checking whether you can index the given container with the given key/index. It's basically doing [key] and telling you whether it's there. So, it doesn't make sense that it would have lower efficiency. This has been discussed before, and while some people would like to be able to use opIn at higher complexities, that's not the way that it's intended to be used, so we're not about to make it work that way for built-in arrays. - Jonathan M DavisIf 'in' operator was overladable, users would expect it to have some known complexity.Like O(n) for a linear search in an array.
Jan 08 2011
On Saturday 08 January 2011 18:10:01 Daniel Gibson wrote:Am 09.01.2011 03:03, schrieb Jonathan M Davis:Probably. Shamefully, if I'm not careful, I tend to mix those up if I don't look them up. Regardless, it's whatever the complexity is to access a node on a balanced, binary tree.On Saturday 08 January 2011 16:19:21 bearophile wrote:"restricted to n log(n)"? I think you meant just "log(n)"BlazingWhitester:opIndex is supposed to be restricted to n log(n), I belive (the complexity necessary to access an element in a balanced, binary tree). It can have lower complexity - like O(1) - but it's not supposed to have higher complexity. opIn is effectively the operator for checking whether you can index the given container with the given key/index. It's basically doing [key] and telling you whether it's there. So, it doesn't make sense that it would have lower efficiency. This has been discussed before, and while some people would like to be able to use opIn at higher complexities, that's not the way that it's intended to be used, so we're not about to make it work that way for built-in arrays. - Jonathan M DavisIf 'in' operator was overladable, users would expect it to have some known complexity.Like O(n) for a linear search in an array.As far as I remember the last discussion, it was considered to allow it for arrays of a constant size or with known (at compiletime) contents or something like that. But then again, that would feel kind of inconsistent (syntax is allowed for fixed size arrays but not for dynamic arrays).Something like that. I'd have to look at the discussion again to know exactly how it all went, but it was definitely the outcome that we're not going to have opIn on built-in arrays. - Jonathan M Davis
Jan 08 2011
On 1/8/11 8:10 PM, Daniel Gibson wrote:Am 09.01.2011 03:03, schrieb Jonathan M Davis:But the reason is rock solid. Consistency is important, but it's not everything. Oh, I just realized - we could have sortedRange define opIn_r! AndreiOn Saturday 08 January 2011 16:19:21 bearophile wrote:"restricted to n log(n)"? I think you meant just "log(n)" As far as I remember the last discussion, it was considered to allow it for arrays of a constant size or with known (at compiletime) contents or something like that. But then again, that would feel kind of inconsistent (syntax is allowed for fixed size arrays but not for dynamic arrays).BlazingWhitester:opIndex is supposed to be restricted to n log(n), I belive (the complexity necessary to access an element in a balanced, binary tree). It can have lower complexity - like O(1) - but it's not supposed to have higher complexity. opIn is effectively the operator for checking whether you can index the given container with the given key/index. It's basically doing [key] and telling you whether it's there. So, it doesn't make sense that it would have lower efficiency. This has been discussed before, and while some people would like to be able to use opIn at higher complexities, that's not the way that it's intended to be used, so we're not about to make it work that way for built-in arrays. - Jonathan M DavisIf 'in' operator was overladable, users would expect it to have some known complexity.Like O(n) for a linear search in an array.
Jan 08 2011
Daniel Gibson napisa=B3:"restricted to n log(n)"? I think you meant just "log(n)" =20 As far as I remember the last discussion, it was considered to allow it f=or=20arrays of a constant size or with known (at compiletime) contents or some=thing=20like that. But then again, that would feel kind of inconsistent (syntax is allowed f=or=20fixed size arrays but not for dynamic arrays).If it's about compile-time, it can be done with template wizardry: x in [1, 5, 7] -> x.in_!(1, 5, 7) --=20 Tomek
Jan 09 2011
Am 09.01.2011 14:56, schrieb Tomek Sowiñski:Daniel Gibson napisa³:Better yet, we could implement kind of Perl6 junctions. Just let anyOf(....) return a custom struct with overloaded operators which just do the operation on all operands and reduces the results with or (ie ||). x == anyOf(3,4,5,42) x == anyBetween(3, 12) D is just great."restricted to n log(n)"? I think you meant just "log(n)" As far as I remember the last discussion, it was considered to allow it for arrays of a constant size or with known (at compiletime) contents or something like that. But then again, that would feel kind of inconsistent (syntax is allowed for fixed size arrays but not for dynamic arrays).If it's about compile-time, it can be done with template wizardry: x in [1, 5, 7] -> x.in_!(1, 5, 7)
Jan 09 2011
Tomek Sowiñski:If it's about compile-time, it can be done with template wizardry: x in [1, 5, 7] -> x.in_!(1, 5, 7)Or better, as a built in feature of arrays :-) But the asymmetry between literals and normal arrays is silly. Bye, bearophile
Jan 09 2011
bearophile napisa=B3:tead ? =20Also, IMO, it has no real advantage, why not use std.algorithm.find ins==20 The syntax is worse, I don't like to call a function for something so com=mon and basic. It's like calling a libraryfunction to join two strings (and find("hello", "llox") doesn't return a =boolean). That can be pretty much solved with a wrapper: bool has(alias pred =3D "a =3D=3D b", R, E)(R haystack, E needle) { return find(haystack, needle).empty; } ------- if (someString.has(c)) ... Can we add 'has' (or call it 'contains', I don't mind) to std.algorithm and= end the discussion? --=20 Tomek
Jan 09 2011
On 9/01/11 1:28 PM, Tomek Sowiński wrote:bearophile napisał:What's wrong with std.algorithm.canFind? http://www.digitalmars.com/d/2.0/phobos/std_algorithm.html#canFindThat can be pretty much solved with a wrapper: bool has(alias pred = "a == b", R, E)(R haystack, E needle) { return find(haystack, needle).empty; } ------- if (someString.has(c)) ... Can we add 'has' (or call it 'contains', I don't mind) to std.algorithm and end the discussion?Also, IMO, it has no real advantage, why not use std.algorithm.find instead ?The syntax is worse, I don't like to call a function for something so common and basic. It's like calling a library function to join two strings (and find("hello", "llox") doesn't return a boolean).bool canFind(alias pred = "a == b", Range, V)(Range range, V value); Returns true if and only if value can be found in range. PerformsΟ(r.length) evaluations of pred.
Jan 09 2011
Peter Alexander napisa=B3:What's wrong with std.algorithm.canFind? =20 http://www.digitalmars.com/d/2.0/phobos/std_algorithm.html#canFindThat I didn't.. er.. find it :) Sorry for the noise. --=20 Tomek
Jan 09 2011
Tomek Sowi=F1ski napisa=B3:One more thing: the overload for range in range search is missing. On the o= ther hand, it's the only overload indexOf has, the other two are missing. --=20 TomekWhat's wrong with std.algorithm.canFind? =20 http://www.digitalmars.com/d/2.0/phobos/std_algorithm.html#canFind =20=20 That I didn't.. er.. find it :) Sorry for the noise.
Jan 09 2011
Peter Alexander:What's wrong with std.algorithm.canFind?I will have to use it, then. Thank you for all the answers. Bye, bearophile
Jan 09 2011
On 08/01/11 23:20, bearophile wrote:Andrei has recently closed issue 1323, it's a small but very useful feature, so I suggest some public discussion: http://d.puremagic.com/issues/show_bug.cgi?id=1323 Lines like this is present thousands of time in my Python code: n in [1, 2, 3] c in "hello" "llo" in some_string Bye, bearophileI'd be all for this, except it's inconsistent. ---- auto arr = [ "foo" : 1, "bar" : 2 ]; assert("foo" in arr); ---- in for associative arrays works by key, if it works by value for normal arrays it's inconsistent, and if it works for keys people will wonder why it's not working as expected. This said, you could do something like the following: ---- import tango.core.Array; struct Arr(T) { T[] a; bool opIn_r(T val) { return a.find(val) != a.length; } } void main() { auto myArr = Arr([1, 2, 3]); assert(1 in myArr); } ---- I'm sure with some alias this magic from D2 you could make this function in an even nicer fashion. -- Robert http://octarineparrot.com/
Jan 08 2011
On 1/8/11 8:07 PM, Robert Clipsham wrote:On 08/01/11 23:20, bearophile wrote:That's what I'm saying, in could work for literal arrays. AndreiAndrei has recently closed issue 1323, it's a small but very useful feature, so I suggest some public discussion: http://d.puremagic.com/issues/show_bug.cgi?id=1323 Lines like this is present thousands of time in my Python code: n in [1, 2, 3] c in "hello" "llo" in some_string Bye, bearophileI'd be all for this, except it's inconsistent. ---- auto arr = [ "foo" : 1, "bar" : 2 ]; assert("foo" in arr); ---- in for associative arrays works by key, if it works by value for normal arrays it's inconsistent, and if it works for keys people will wonder why it's not working as expected.
Jan 08 2011
On 01/09/2011 03:07 AM, Robert Clipsham wrote:On 08/01/11 23:20, bearophile wrote:No, people will not wonder about that. See also: python. Seriously people, stop giving this as a reason. A much better argument is the in operator should run in O(log n) for anything, meaning it won't work for a general unsorted array. I suggest going for (v in assumeSorted(arr)) or (arr.contains(v)), where contains is the canFind function blessed with a new, superior name. :-)Andrei has recently closed issue 1323, it's a small but very useful feature, so I suggest some public discussion: http://d.puremagic.com/issues/show_bug.cgi?id=1323 Lines like this is present thousands of time in my Python code: n in [1, 2, 3] c in "hello" "llo" in some_string Bye, bearophileI'd be all for this, except it's inconsistent. ---- auto arr = [ "foo" : 1, "bar" : 2 ]; assert("foo" in arr); ---- in for associative arrays works by key, if it works by value for normal arrays it's inconsistent, and if it works for keys people will wonder why it's not working as expected.
Jan 09 2011
On 9/01/11 4:28 PM, Pelle wrote:On 01/09/2011 03:07 AM, Robert Clipsham wrote:The inconsistency doesn't just affect readability, it's an issue of generic programming, too. e.g. bool containsAny(R1, R2)(R1 haystack, R2 needles) { foreach (needle; needles) if (needle in haystack) return true; return false; } For hashtables, containsAny would look up keys, and for arrays it would look up values, which might not be obvious to the user of containsAny. Also, I'm of the opinion that T[] should be replaceable with T[size_t] in most cases, and the differing semantics of 'in' would break that. string[int] days1 = [0: "Sunday", 1: "Monday", ... ]; string[] days2 = ["Sunday", "Monday", ... ]; assert( days1[6] == "Saturday" ); // pass assert( days2[6] == "Saturday" ); // pass assert( "Saturday" in days1 ); // fail assert( "Saturday" in days2 ); // pass Personally I think that the semantics of 'in' for AAs should change to use values, but I doubt that's going to happen at this stage (if ever).I'd be all for this, except it's inconsistent. ---- auto arr = [ "foo" : 1, "bar" : 2 ]; assert("foo" in arr); ---- in for associative arrays works by key, if it works by value for normal arrays it's inconsistent, and if it works for keys people will wonder why it's not working as expected.No, people will not wonder about that. See also: python. Seriously people, stop giving this as a reason.
Jan 09 2011
On 1/9/11 10:28 AM, Pelle wrote:On 01/09/2011 03:07 AM, Robert Clipsham wrote:I'd be glad to change canFind to contains. Vote by replying to this. We can put canFind on the slow deprecation chute. AndreiOn 08/01/11 23:20, bearophile wrote:No, people will not wonder about that. See also: python. Seriously people, stop giving this as a reason. A much better argument is the in operator should run in O(log n) for anything, meaning it won't work for a general unsorted array. I suggest going for (v in assumeSorted(arr)) or (arr.contains(v)), where contains is the canFind function blessed with a new, superior name. :-)Andrei has recently closed issue 1323, it's a small but very useful feature, so I suggest some public discussion: http://d.puremagic.com/issues/show_bug.cgi?id=1323 Lines like this is present thousands of time in my Python code: n in [1, 2, 3] c in "hello" "llo" in some_string Bye, bearophileI'd be all for this, except it's inconsistent. ---- auto arr = [ "foo" : 1, "bar" : 2 ]; assert("foo" in arr); ---- in for associative arrays works by key, if it works by value for normal arrays it's inconsistent, and if it works for keys people will wonder why it's not working as expected.
Jan 09 2011
Am 09.01.2011 19:44, schrieb Andrei Alexandrescu:On 1/9/11 10:28 AM, Pelle wrote:Yeah, "contains" sounds better than "canFind", so ++voteOn 01/09/2011 03:07 AM, Robert Clipsham wrote:I'd be glad to change canFind to contains. Vote by replying to this. We can put canFind on the slow deprecation chute. AndreiOn 08/01/11 23:20, bearophile wrote:No, people will not wonder about that. See also: python. Seriously people, stop giving this as a reason. A much better argument is the in operator should run in O(log n) for anything, meaning it won't work for a general unsorted array. I suggest going for (v in assumeSorted(arr)) or (arr.contains(v)), where contains is the canFind function blessed with a new, superior name. :-)Andrei has recently closed issue 1323, it's a small but very useful feature, so I suggest some public discussion: http://d.puremagic.com/issues/show_bug.cgi?id=1323 Lines like this is present thousands of time in my Python code: n in [1, 2, 3] c in "hello" "llo" in some_string Bye, bearophileI'd be all for this, except it's inconsistent. ---- auto arr = [ "foo" : 1, "bar" : 2 ]; assert("foo" in arr); ---- in for associative arrays works by key, if it works by value for normal arrays it's inconsistent, and if it works for keys people will wonder why it's not working as expected.
Jan 09 2011
Daniel Gibson:Yeah, "contains" sounds better than "canFind", so ++voteIn my dlibs1 I have used isIn(), but contains() is better than canFind(). Bye, bearophile
Jan 09 2011
Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:I'd be glad to change canFind to contains. Vote by replying to this. We can put canFind on the slow deprecation chute.Absolutely. canFind always sounded to me like "this container supports find". -- Simen
Jan 09 2011
Andrei Alexandrescu napisa=B3:I'd be glad to change canFind to contains. Vote by replying to this. We=20 can put canFind on the slow deprecation chute.Like!
Jan 09 2011
On 9/01/11 7:15 PM, Tomek Sowiński wrote:Andrei Alexandrescu napisał:Up vote for me.I'd be glad to change canFind to contains. Vote by replying to this. We can put canFind on the slow deprecation chute.Like!
Jan 09 2011
On 1/9/11 7:44 PM, Andrei Alexandrescu wrote:I'd be glad to change canFind to contains. Vote by replying to this. We can put canFind on the slow deprecation chute.Changing the name to »contains« has my vote as well – »canFind« always sounds like a check whether the container can perform »find« to me… David
Jan 09 2011
While you're at it I would really like to have a remove method in std.algorithm that can take an ElementType of a range as a predicate: See my older topic: http://www.digitalmars.com/d/archives/digitalmars/D/learn/Removing_an_object_from_a_range_23212.html An example would look like: Object a, b, c; Object[] arr = [a, b, c]; remove(arr, b) // arr == [a, c]; Or should I just file this in bugzilla as a feature request?
Jan 09 2011
On 1/9/11 1:30 PM, Andrej Mitrovic wrote:While you're at it I would really like to have a remove method in std.algorithm that can take an ElementType of a range as a predicate: See my older topic: http://www.digitalmars.com/d/archives/digitalmars/D/learn/Removing_an_object_from_a_range_23212.html An example would look like: Object a, b, c; Object[] arr = [a, b, c]; remove(arr, b) // arr == [a, c]; Or should I just file this in bugzilla as a feature request?An algorithm can't change the topology of the range it works on. Andrei
Jan 09 2011
On 09/01/11 18:44, Andrei Alexandrescu wrote:I'd be glad to change canFind to contains. Vote by replying to this. We can put canFind on the slow deprecation chute. Andrei++vote; -- Robert http://octarineparrot.com/
Jan 09 2011
On 1/9/11 1:24 PM, Robert Clipsham wrote:On 09/01/11 18:44, Andrei Alexandrescu wrote:I just remembered why I called it canFind: it clarifies we're talking of a linear operation (derived from find). "contains" suggests a fast set operation. AndreiI'd be glad to change canFind to contains. Vote by replying to this. We can put canFind on the slow deprecation chute. Andrei++vote;
Jan 09 2011
On Sunday 09 January 2011 10:44:39 Andrei Alexandrescu wrote:On 1/9/11 10:28 AM, Pelle wrote:I would remind you of http://d.puremagic.com/issues/show_bug.cgi?id=4405 where we considered replacing canFind() with any(). I think that contains() is exactly what we should have for the typical case of dealing with finding a specific element in an array or container, but we probably should have any() for the general case where you're looking to see whether the given predicate is true for _any_ element in the range. Adding all() to go along with it (as in it returns true if the given predicate is true for _all_ elements in the range) would be preferable. However, I definitely think that having contains() makes a _lot_ of sense, because that is exactly the function name that most people are looking for when they want to know whether a particular element is in a range. - Jonathan M DavisOn 01/09/2011 03:07 AM, Robert Clipsham wrote:I'd be glad to change canFind to contains. Vote by replying to this. We can put canFind on the slow deprecation chute. AndreiOn 08/01/11 23:20, bearophile wrote:No, people will not wonder about that. See also: python. Seriously people, stop giving this as a reason. A much better argument is the in operator should run in O(log n) for anything, meaning it won't work for a general unsorted array. I suggest going for (v in assumeSorted(arr)) or (arr.contains(v)), where contains is the canFind function blessed with a new, superior name. :-)Andrei has recently closed issue 1323, it's a small but very useful feature, so I suggest some public discussion: http://d.puremagic.com/issues/show_bug.cgi?id=1323 Lines like this is present thousands of time in my Python code: n in [1, 2, 3] c in "hello" "llo" in some_string Bye, bearophileI'd be all for this, except it's inconsistent. ---- auto arr = [ "foo" : 1, "bar" : 2 ]; assert("foo" in arr); ---- in for associative arrays works by key, if it works by value for normal arrays it's inconsistent, and if it works for keys people will wonder why it's not working as expected.
Jan 09 2011