[PATCH] D83419: [clangd] Add error() function for creating formatv-style llvm::Errors. NFC

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 9 00:17:45 PDT 2020


sammccall added a comment.

Honestly, I really dislike names in the style of makeError/createError.
My favorite name for this would be Error (i.e. a constructor) but that would involve redesigning it (which is a good idea, but an impossible yak-shave).
I guess makeError is still better than the status quo, but not enough to feel motivated to clean this up right now. Maybe someone else wants to pick this up?

> I think the key point is that error creates an Error object, and this object must be checked before destructing. error name makes it look like a print function, I'd prefer to add a verb to the name, e.g. makeError

This is exactly backwards IMO - a function used for its value (like this one) doesn't need a verb, a function used for its side-effects (like log) does.
https://swift.org/documentation/api-design-guidelines/#strive-for-fluent-usage seems pretty well-thought-out to me.
LLVM guidelines don't reflect this, but I haven't been able to find anyone making a positive case for them beyond legacy and inertia.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83419





More information about the cfe-commits mailing list