Remove complex and imaginary types?

Daniel919 Daniel919 at web.de
Sat Jan 12 01:48:53 PST 2008


>> Here's my version from a while back:
>> http://www.digitalmars.com/d/archives/digitalmars/D/Suffix-based_literal_syntax_53992.html

I agree,
T opSuff_k(T)(T x) { return x * 1000; }
is better to handle than
T opPostfix("k")(T)(T x) { return x * 1000; }


For example
alias somefunc opSuff_k;
would be too difficult with the other syntax.


> I like a lot all those proposal for adding suffix based literal, but I'm 
> afraid that these could interfere(sp?) with the ones already existing in 
> the language, so I wonder if 'library added' suffix shouldn't have an 
> operator to distinguish them for the language one.
> 
> I'm thinking about the underscore '_': 5.8f_km would be replaced by 
> km(5.8f), if there is no operator, there are some risk of ambiguity: 
> "5.8fm" is-it 5.8f meters or 5.8 femtometers?
> 
> With 5.8f_m and 5.8_fm you remove the ambiguity and the _ is visually 
> 'pleasing' so this syntax would still be used.

What about:
auto a = 5.8f m;
auto b = 5fm; //<=> auto b = 5 fm;
auto c = 5.8f fm;
And the compiler always tries to find the longest match.



More information about the Digitalmars-d mailing list