This is an attempt to reduce the verbose manual dispatching code in APFloat. This doesn't handle multiple dispatch on single discriminator (e.g. APFloat::add(const APFloat&)), nor handles multiple dispatch on multiple discriminators (e.g. APFloat::convert()).
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Other than the naming nit, this seems like an improvement to me.
llvm/include/llvm/ADT/APFloat.h | ||
---|---|---|
24 ↗ | (On Diff #85843) | What does "single" refer to here? APFLOAT_SEMANTIC_DISPATCH? I don't really like that either. Maybe someone else has a better suggestion. |
llvm/include/llvm/ADT/APFloat.h | ||
---|---|---|
24 ↗ | (On Diff #85843) | APFLOAT_FORMAT_DISPATCH ? |
llvm/include/llvm/ADT/APFloat.h | ||
---|---|---|
24 ↗ | (On Diff #85843) | I like that one. |
llvm/include/llvm/ADT/APFloat.h | ||
---|---|---|
24 ↗ | (On Diff #85843) | For single dispatch, see https://en.m.wikipedia.org/wiki/Dynamic_dispatch#Single_and_multiple_dispatch . Here the macro expands to code that dispatches on "*this" APFloat object. This isn't the case for add or convert. |
llvm/include/llvm/ADT/APFloat.h | ||
---|---|---|
24 ↗ | (On Diff #85843) | Most people will read the macro as a "what are we doing" rather than "how are we doing it" I think which is why I suggested format. |
llvm/include/llvm/ADT/APFloat.h | ||
---|---|---|
24 ↗ | (On Diff #85843) | I actually don't know what "format" means here. How about APFLOAT_DISPATCH? :) |
llvm/include/llvm/ADT/APFloat.h | ||
---|---|---|
24 ↗ | (On Diff #85843) | You could also use layout dispatch. The idea is the "format" of the float. I just don't like layout, but that's also fine if you'd prefer it. |
llvm/include/llvm/ADT/APFloat.h | ||
---|---|---|
24 ↗ | (On Diff #85843) | I see. Some how "format" reminded me of format string... oh well. Then the consistent term to use here is "semantics". How about APFLOAT_DISPATCH_ON_SEMANTICS? |
llvm/include/llvm/ADT/APFloat.h | ||
---|---|---|
24 ↗ | (On Diff #85843) | I'm also fine with that. |