Project Elvis

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Oct 28 11:38:52 UTC 2017


Walter and I decided to kick-off project Elvis for adding the homonym 
operator to D.

Razvan Nitu has already done a good part of the work:

https://github.com/dlang/dmd/pull/7242
https://github.com/dlang/dlang.org/pull/1917
https://github.com/dlang/dlang.org/pull/1918

What's needed is a precise DIP that motivates the feature properly and 
provides a good proposal for it. I'm no fan of bureaucracy but we really 
need to be pedantic about introducing language features. Walter argued 
thusly in a PR, and I agree:

"I'm concerned that the elvis operator is not well understood, and we 
shouldn't be designing it in the comments section here. A DIP needs to 
be written. Things like operator precedence, side effects, type 
resolution, comparison with the operator in other languages, grammar 
changes, lvalues, how it would appear in the generated .di file if it 
isn't its own operator, etc., should be addressed."

A lowering looks like the straightforward approach, of the kind:

expr1 ?: expr2

==>

(x => x ? x : expr2)(expr1)

Who wants to join Razvan in Project Elvis?


Thanks,

Andrei


More information about the Digitalmars-d mailing list