Does D have too many features?

Alex Rønne Petersen xtzgzorex at gmail.com
Tue May 1 08:11:24 PDT 2012


On 01-05-2012 16:41, SomeDude wrote:
> On Tuesday, 1 May 2012 at 14:31:25 UTC, Alex Rønne Petersen wrote:
>>
>> 1) So because some people might use a feature incorrectly due to lack
>> of knowledge in algorithms and data structures, we should cripple the
>> language?
>
> It's not crippling the language. Nothing prevents you from writing a loop.
> Or using a library find function that does the same thing. But the name
> "find" gives you a hint that it's not magical and that it has a cost,
> while with "if( foo in bar)", it is too easy to forget that we are
> actually potentially performing an O(n) operation. In an AA, the 'in'
> keyword performs a O(1) operation, so that's ok to use it as a syntactic
> sugar.
>
>

No, it is not an O(1) operation, it is *close* to O(1) (as much sense as 
that statement can make). I don't know why you associate any particular 
complexity with 'in' in the first place. And I do think we're crippling 
the language, considering Python (and probably other languages) has had 
this feature since forever.

I'm seriously worried. It seems to me like we're trying to cater to 
people who can't reason about the types in their program and the 
complexities of performing various operations on them. Since when did 
algorithmic complexity become a reason to take away syntax sugar?

-- 
- Alex


More information about the Digitalmars-d mailing list