opImplicitCast/opImplicitCastFrom

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Oct 30 13:22:58 PDT 2008


bearophile wrote:
> Andrei Alexandrescu:
>> Why worry about syntax?
> 
> Because from past experience I have seen that having a suitable
> syntax helps focus the mind a little. While when I discuss a feature
> in "abstract" most people just ignore what I have written.

I agree many people can work easier on concrete examples.

> And
> because the absence/presence of a natural-looking syntax is often a
> sign that the semantics of something is muddy/clear.

I do not agree with that. I can't see myself at the end of a train of 
thoughts leading to the above, as right now I have (as far as D is 
concerned) an embarrassment of riches in terms of concepts that are 
well-understood but for which devising a simple syntax is difficult. 
Saving on syntax can have many other causes, most of which are prevalent 
in a language that tries to stay slim. Put another way, there are much 
more things that are clear without a simple syntax, than things that are 
unclear with a simple syntax.

>> The nice thing about those is that they allow you to specify
>> infinite behavioral variations via policies. For example, you'd
>> want to choose the behavior on overflow to be e.g. throwing,
>> unchecked, or wraparound:
> 
> It's also useful to follow the 80/20 rule, to avoid making the
> semantics of this overly complex, increasing the complexity to give
> the programmer the possibility of specifying cases that aren't
> common. That's why the lambdas of C++ have an horrible design, they
> are over-generalized, while 95% of the times people need just a basic
> lambda (and in the other 5% of the cases the user can write a normal
> function/class manually). The "wraparound" seems not much useful to
> me.

But the wraparound is probably the most principled of all; it's linked
to modulo arithmetic.

Anyhow... I'm not an expert on C++ lambdas. How are they overly general?


Andrei



More information about the Digitalmars-d mailing list