yank unary '+'?

Walter Bright newshound1 at digitalmars.com
Sun Dec 6 12:29:28 PST 2009


Andrei Alexandrescu wrote:
> Is there any good use of unary +? As an aside, Perl programs do use it 
> occasionally for syntactic disambiguation :o).

An internet search reveals:

1. symmetry

2. compatibility with C and many other languages that use it

3. used with operator overloading to convert a user defined type to its 
preferred arithmetic representation (a cast can't know what the 
'preferred' type is)

4. to create DSL languages, like Spirit, as Kenny points out

5. to coerce default integral promotion rules (again, cast(int) won't 
always produce the same result)

6. to visually emphasize that a literal is positive

I say leave it in.



More information about the Digitalmars-d mailing list