[PATCH] D99561: Support visitor pattern by PointerUnion.

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 6 17:41:07 PDT 2021


dblaikie added a comment.

In D99561#2672814 <https://reviews.llvm.org/D99561#2672814>, @mehdi_amini wrote:

>> also the issue of "Oh, I'm used to using x.match(a, b) - ah, bother, this is the standard thing that doesn't support x.match, I have to use visit(a, b, x) instead".
>
> The same thing could be said about many of our APIs in Support/ADT which we make in a form that we think is more convenient than the standard, like how `llvm::sort` and all the others we have don't need `.begin()`/`.end()` to operate on the entire range. I'm annoyed every time I have to an `std::` entry point that forces me in the extra boilerplate, but I wouldn't want to remove these nicer APIs from LLVM for "consistency with the standard".
> (don't forget also that the standard often will have constraint around API design we don't have, for example around exception handling).

To be sure - though I think the algorithm wrappers we implement (like `sort(R)` instead of `sort(begin, end)`) don't produce the same sort of confusion that I think this could. The sort ones work on all containers in either version, so you don't end up reaching for one that only works on LLVM data structures and then find out you had a standard container and can't use it, or the other way around.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99561/new/

https://reviews.llvm.org/D99561



More information about the llvm-commits mailing list