Keith said:
Incidentally, I don't believe that a C program can use operator
overloading without violating either a constraint or a syntax rule.
My understanding is that the existence of an extension does not
relieve the compiler of its obligation to issue a diagnostic for any
such program; after issuing the diagnostic, it's then free to go on
and handle the extension as it likes. (Of course, this applies only
in conforming mode; a compiler is perfectly free to *silently* accept
operator loading, or do anything else it likes, in a non-conforming
mode.)
So, in conforming mode, a compiler can either (a) reject the use of
operator overloading, or (b) accept it, but only after issuing a
diagnostic. Failure to issue the diagnostic would be a violation of
the standard.
This is very interesting.
This would mean that I am allowed to use the operator overloading
extension (and stop all internal contorsions) in conforming mode,
what would allow me to implement completely complex types and
extended precision types in the same fashion and take that code
OUT from the compiler...
The only difficult point comes to initialization.
C99 declares that
double _Complex val = 568.67+78.87*I;
is a complex number. There is no accepted way to do
this by using operator overloading either in C or C++...
Somehow the compiler has "to know" those types. The same for
the extended precision floats:
qfloat m = 4544666788766544545455454e9567Q;
(Note the 'Q' at the end)
I would have to design some kind of syntax to call a user function
during compile time to parse this kind of new numbers.
#pragma NumberLexer('Q',qfloat,ReadQfloat,"Qfloat.dll")
mening:
"When you find a number that ends in 'Q', call the function ReadQfloat
in the "Qfloat.dll". That function will fill the qfloat type using the
parsed number.
In a Unix environment it would be:
#pragma NumberLexer('Q',qfloat,ReadQfloat,"libqfloat.so")