Exponential operator
Don
nospam at nospam.com
Mon Aug 10 00:04:26 PDT 2009
Miles wrote:
> 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.
That doesn't work, because you still get new code being converted from
C. It can't look the same, but behave differently.
>
> Other examples:
>
> a-- - b
> a - --b
>
> a && b
> a & &b
You didn't respond to my assertion: even if you _could_ do it, why would
you want to? ** sucks as an exponential operator. I dispute the
contention that ** is a natural choice. It comes from the same language
that brought you IF X .NE. 2
More information about the Digitalmars-d
mailing list