Remove complex and imaginary types?
Sean Kelly
sean at f4.ca
Tue Jan 8 07:30:18 PST 2008
Walter Bright wrote:
> Georg Wrede wrote:
>
>>> The remaining advantage is that of imaginary literals, i.e. the i
>>> postfix:
>>>
>>> 3 + 5i
>>
>> I'd really like to reserve the above phrase to be reserved to mean an
>> imaginary number. If one has the library delivered right with the
>> standard compiler or if one has to walk around the Globe in search of
>> the One library that actually implements it, I'd still want to have
>> this particular notation reserved (in the Language Grammar itself) for
>> this particular purpose.
>
> I do too. And been thinking along the lines of simply putting a hack in
> that the postfix 'i' means that it's a literal of type 'imaginary', and
> the compiler looks to see if "std.complex" was imported.
>
> This isn't as outlandish as it sounds, as there's precedent for it both
> in C++ <typeinfo> and java.lang.String, as well as D's Object.
I thought the standard library's inclusion in the language spec was one
of the things you disliked about C++. Though you're right there is
effective precedent for it, with the compiler recognizing std.intrinsic
and various parts of std.math as a QOI feature. However, this has
proven to be quite a headache for libraries with alternate path schemes,
like Tango. I'll admit to also being a bit concerned that this may
produce another binding between the runtime and standard library, much
like the regex features did. I'm all for retaining imaginary literals,
but I hope the solution is carefully considered.
Sean
More information about the Digitalmars-d
mailing list