Zcoin implementation bug enabled attacker to create 548, 000 Zcoins

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Sat Mar 11 14:35:12 PST 2017


On 11.03.2017 20:39, H. S. Teoh via Digitalmars-d wrote:
> On Sat, Mar 11, 2017 at 01:46:31PM +0100, Timon Gehr via Digitalmars-d wrote:
>> On 10.03.2017 23:41, H. S. Teoh via Digitalmars-d wrote:
>>>
>>> Basically, operator syntax is just too specific to the arithmetical
>>> meanings of the operators that overloading them to mean something
>>> else seems like just asking for trouble.
>>
>> OTOH, restricting how operators can be overloaded means they cannot be
>> used for symbolic mathematics, which is annoying.
>
> I think you misunderstand my intent.

I'm not disagreeing with your point, I'm just adding that the language 
should not necessarily attempt to enforce it.


> By "arithmetical meanings" I meant
> any meanings to which mathematics may assign to said operators, so using
> "x + y" for vector addition, for example, is fair game. And perhaps even
> field addition for general fields. But using "x + y" for division is
> abusive, for example, and so is using "+" for appending to a file.
>
> But in any case, this isn't something that's enforceable. Deciding
> whether an implementation of an overload of "+" is "addition-like" is
> probably undecidable.

It's the same with "<=", and the current approach has false negatives.


> It's just bad practice to use "+" for something
> that someone reading the code wouldn't expect. The bottom line is really
> readability and maintainability than anything else.
>
>
> T
>

This is not really specific to operators at all though. The general 
point is that functions should be named reasonably.


More information about the Digitalmars-d mailing list