Short list with things to finish for D2

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Wed Nov 18 17:06:31 PST 2009


grauzone wrote:
> bearophile wrote:
>> Andrei Alexandrescu:
>>
>>> * Encode operators by compile-time strings. For example, instead of 
>>> the plethora of opAdd, opMul, ..., we'd have this:
>>>
>>> T opBinary(string op)(T rhs) { ... }
>>>
>>> The string is "+", "*", etc.
> 
> I thought the problem with this was that the lexer/parser would have to 
> know about semantics, which is against the goals of the language. Would 
> the operator actually be inside quotes?

It's simpler than that.

a + b

will be rewritten into

a.opBinary!("+")(b)

The rewrite is done long after lexing, so no low-level problems there.

> Anyway, do we _really_ want to make it possible, that valid D code will 
> look like ASCII art?

We want to improve the state of the art. If the attempt risks to end up 
doing the opposite, I'm all ears.


Andrei



More information about the Digitalmars-d mailing list