"in" everywhere
so
so at so.do
Sat Oct 9 01:54:17 PDT 2010
On Thu, 07 Oct 2010 17:52:10 +0300, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:
> On 10/7/10 6:54 CDT, atommixz wrote:
>> It would be nice if it were possible to use the "in" expression wherever
>> possible. Now it is only implemented for associative. arrays. (Weird).
>> Examples of how this could be used:
>> - Find string in string
>> - Search for a character in a string
>> - Search for an item in the array, array of characters, array of
>> strings,
>> tuples, enum, structure
>> - what else?
>>
>> In Python done something like this.
>>
>> Here it would be useful to me
>> http://code.google.com/p/atommixz/source/browse/analyze-x86/analyze-x86.py
>> http://code.google.com/p/atommixz/source/browse/analyze-x86/analyzex86.d
>
> I'm a bit leary of adopting this feature (it has been discussed). To me
> "in" implies a fast operation and substring searching isn't quite it.
>
> One thing that could be done is to allow "in" with literal arrays to
> their right:
>
> if (x in ["abcde", "asd"]) { ... }
>
> The size of the operand is constant, known, and visible.
>
>
> Andrei
Reading these boards, both new and old posts, i hardly find any topic that
i disagree with you.
This one is one of those rare cases.
It is really hard for me to connect "operator usage" and "operation
complexity". To me, operators are just "cute", and mostly meaningful (and
not necessarily) shortcuts.
You can overload any operator, doesn't matter what it says/feels, you can
do pretty much anything you like, on any complexity level.
Either purge it (you get Java) or lift the restrictions and let coder have
it.
Thanks.
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
More information about the Digitalmars-d
mailing list