D - 'in' would be nice for normal arrays, too...
- Russell Lewis (19/19) Sep 25 2002 I'm running across places in my code where I want to test an array for
- Burton Radons (3/13) Sep 25 2002 I agree, this should be valid, even though the implementation will just
- Walter (3/22) Sep 29 2002 I think this is a great and natural idea. Thanks!
- Dario (5/24) Oct 10 2002 If it were valid, the "in" sintax wouldn't need to be valid for
- Russ Lewis (11/39) Oct 11 2002 This actually might be a very good idea, since a programmer might want t...
I'm running across places in my code where I want to test an array for the existence of a certain value: Foo[] array; Foo value; // need to check: is value in array? if(value in array) // this doesn't work, so far { .. } Right now, I'm wavering. In one place, I created an associative array of bits, and then I get the "keys" property to get the real values: bit[Foo] array; Foo value; if(value in array) // this works { .. } In another, I'm thinking of writing an actual search function. Perhaps a wishlist item, I suppose...
Sep 25 2002
Russell Lewis wrote:I'm running across places in my code where I want to test an array for the existence of a certain value: Foo[] array; Foo value; // need to check: is value in array? if(value in array) // this doesn't work, so far { .. }I agree, this should be valid, even though the implementation will just be a linear search. Marked in TODO.
Sep 25 2002
I think this is a great and natural idea. Thanks! "Russell Lewis" <spamhole-2001-07-16 deming-os.org> wrote in message news:3D91E904.2080409 deming-os.org...I'm running across places in my code where I want to test an array for the existence of a certain value: Foo[] array; Foo value; // need to check: is value in array? if(value in array) // this doesn't work, so far { .. } Right now, I'm wavering. In one place, I created an associative array of bits, and then I get the "keys" property to get the real values: bit[Foo] array; Foo value; if(value in array) // this works { .. } In another, I'm thinking of writing an actual search function. Perhaps a wishlist item, I suppose...
Sep 29 2002
I'm running across places in my code where I want to test an array for the existence of a certain value: Foo[] array; Foo value; // need to check: is value in array? if(value in array) // this doesn't work, so far { .. } Right now, I'm wavering. In one place, I created an associative array of bits, and then I get the "keys" property to get the real values: bit[Foo] array; Foo value; if(value in array) // this works { .. } In another, I'm thinking of writing an actual search function. Perhaps a wishlist item, I suppose...If it were valid, the "in" sintax wouldn't need to be valid for associative arrays, since you would be able to write "key in assArray.keys;" This should be optimized by the compiler and can decrease the language complexity (and maybe the compiler's one), though increasing the typing. Just thoughts.
Oct 10 2002
Dario wrote:This actually might be a very good idea, since a programmer might want to know if a value is "in keys" or "in values". I would support doing this. Disallow the "in" property for associative arrays, but make an explicit suggestion that the compiler optimize for "value in assocArray.keys" and "value in assocArray.values". -- The Villagers are Online! http://villagersonline.com .[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ] .[ (a version.of(English).(precise.more)) is(possible) ] ?[ you want.to(help(develop(it))) ]I'm running across places in my code where I want to test an array for the existence of a certain value: Foo[] array; Foo value; // need to check: is value in array? if(value in array) // this doesn't work, so far { .. } Right now, I'm wavering. In one place, I created an associative array of bits, and then I get the "keys" property to get the real values: bit[Foo] array; Foo value; if(value in array) // this works { .. } In another, I'm thinking of writing an actual search function. Perhaps a wishlist item, I suppose...If it were valid, the "in" sintax wouldn't need to be valid for associative arrays, since you would be able to write "key in assArray.keys;" This should be optimized by the compiler and can decrease the language complexity (and maybe the compiler's one), though increasing the typing. Just thoughts.
Oct 11 2002