Exponential operator
Miles
_______ at _______.____
Fri Aug 7 09:33:09 PDT 2009
Lars T. Kyllingstad wrote:
> Neither of the natural candidates, a^b and a**b, are an option, as they
> are, respectively, already taken and ambiguous.
I think that a ** b can be used, is not ambiguous except for the
tokenizer of the language. It is the same difference you have with:
a ++ b -> identifier 'a', unary operator '++', identifier 'b' (not
parseable)
a + + b -> identifier 'a', binary operator '+', unary operator '+',
identifier 'b' (parseable)
I don't know anyone who writes ** to mean multiplication and
dereference, except when obfuscating code. People usually prefer adding
a whitespace between both operators, for obvious readability purposes.
I think it is perfectly reasonable to deprecate current usage of '**'
for the next release, and a few releases later, make '**' a new
operator. I doubt anyone would notice.
Other examples:
a-- - b
a - --b
a && b
a & &b
More information about the Digitalmars-d
mailing list