in operator generalization

BCS BCS_member at pathlink.com
Fri Mar 17 15:26:45 PST 2006


Les Baker wrote:
> Looking through old NG posts I found this one by Ben Hinkle last year 
> about extending the "in" operator to support static/dynamic arrays.
> 
> http://www.digitalmars.com/d/archives/digitalmars/D/25164
> 
> Was this ever totally dismissed?  It just seemed to fall off the radar. 
>  I'm liking the concept though; I don't know how many times I've written 
> loops in quickie utility programs just to hunt for a item and return 
> it.  I would also additionally suggest (if it hasn't already been) that 
> "in" be overloadable so that if D supports other data structures in the 
> standard library that they can use that syntax as well.
> 
> The only disadvantage I can think of is that when a developer sees "in", 
> he/she can't assume it's a constant time operation anymore.  I think the 
> increase in utility outweights that though.
> 
> Thoughts?
> 
> Les Baker

Actually this would be backwards, "in" determines if the given value is a key 
for the AA. Using it to examine the contents would be something different than 
it's current meaning, but this might not be a bad idea.



More information about the Digitalmars-d mailing list