This is an archive of the discontinued LLVM Phabricator instance.

[APFloat] Remove neg in favour of unary operator-
AbandonedPublic

Authored by foad on Mar 3 2020, 3:20 AM.

Diff Detail

Event Timeline

foad created this revision.Mar 3 2020, 3:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 3 2020, 3:20 AM
ekatz added a comment.Mar 3 2020, 6:44 AM

This is a simple change, so generally it looks good, but I have to ask:
What is the reason for it? I do understand why you want to add functionality (the operator- in the other change), but I am not sure why to remove.

foad added a comment.Mar 3 2020, 8:20 AM

What is the reason for it? I do understand why you want to add functionality (the operator- in the other change), but I am not sure why to remove.

Just the general principle of cleaning up after yourself. I think it's silly to have two different names for a simple negation function. If you only ever add functionality, and never remove the old obsoleted functionality, you'll end up with a lot of useless old cruft in your codebase.

What is the reason for it? I do understand why you want to add functionality (the operator- in the other change), but I am not sure why to remove.

Just the general principle of cleaning up after yourself. I think it's silly to have two different names for a simple negation function. If you only ever add functionality, and never remove the old obsoleted functionality, you'll end up with a lot of useless old cruft in your codebase.

Some C++ programming styles discourage using overloaded operators, because functions express programmer's intentions clearer.

foad added a comment.Mar 3 2020, 8:59 AM

Some C++ programming styles discourage using overloaded operators, because functions express programmer's intentions clearer.

Sure, but I don't see anything in the LLVM Programmer’s Manual or LLVM Coding Standards that discourages it. And I think overloading arithmetic operators for a numeric type is the sanest possible use of overloading.

ekatz added a comment.Mar 5 2020, 9:20 AM

It is a matter of taste. I actually see the benefits of the clear code when using operator overloads.
The question is, should we remove the explicit function calls?
Lets say we do; I still prefer (above all) a unified coding style. In this case, it interprets as: removing all the other operators. The problem is, with add (for example). It receives a roundingMode as a parameter, which means that we can't remove this function, in exchange to the operator+. We must maintain both.
So, to maintain consistency, I think we should keep neg as well.

foad updated this revision to Diff 248585.Mar 5 2020, 12:55 PM

Update users of neg to use operator- instead.

RKSimon resigned from this revision.Aug 2 2020, 3:04 AM
nikic resigned from this revision.Aug 30 2020, 9:03 AM
foad abandoned this revision.Aug 30 2020, 9:06 AM