-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VOTE: const west or east const #40
Comments
@psychocoderHPC Can you notify the PIConGPU developers and the alpaka developers? Apparently I can't do this myself, maybe I'm missing some permissions. |
|
The argument that east const is more logical because then the On the contrary, the information that a variable is |
(even despite one of my old Reddit accounts was literally EastConst) |
east const, the only consistent const. Especially useful when passing pointers of vectors of unique ptrs of maps of something and trying to find out which parts are mutable. west const randomness: void const_west(
const std::vector<
std::unique_ptr<
std::map< std::string, const float * >
>
> * const x
) {} vs. "what's left is const": 🧑🍳 void east_const(
std::vector<
std::unique_ptr<
std::map< std::string, float const * >
>
> const * const x
) {} |
|
@ComputationalRadiationPhysics/picongpu-developers @ComputationalRadiationPhysics/alpaka-developers |
|
|
|
🍿 |
So as expected east style vs. west is a hot topic. |
Do we have any rules for a tie? |
Invite an odd number of people and let them vote... |
If we have tie, I will choose ;-P |
This is an... odd idea! SCNR 😁 |
but feel free to ignore me |
Unfortunately it does not work that way :/ Your vote counts just as much as the people who really care. If east/west const is not of importance to you, then please do not vote. Please :) |
I really dislike when people bring up such examples. You would very seldomly pass a pointer to Generally, we should pass pointers very rarely, because there is a manifold of better alternatives, like references, smart pointers, pass by value, |
Then please take my vote seriously ;-) |
Yeah I am not making that up, for example I see plenty of cases per day where people have a host-container of pointers to device objects and quickly unwrap the pointer to pass it to a device lambda in-place. Smart pointers don't help here and it's a quick way to get things passed from host to device in lambda-heavy code, so I don't judge them. We are talking C++14 code bases as of today, C++17 transitions potentially this or early next year, etc. (re: C++20 |
Interesting pattern. But this probably stems from CUDA trading device memory regions in pointers which I find questionable. It potentially misleads users into believing they can actually perform operations on a
I think I have to disagree here. The coding guidelines are aiming to set a standard for a wide variety of projects within CRP and teams as CASUS. We cannot assume any C++ version here. That is subject to each project. LLAMA for example is on C++17 and has an optional concept (with is C++20). As for |
As I said, I observe these patterns as of the realities today and I don't judge them.
Everything else is taste, which is what we vote on here.
|
I do not really like east const for constness but I do not see that we will get rid of pointers for heterogeneous apps/libs where we need to pass pointer to the device. Smart pointer will not help with that and I do not believe that we will get smart-pointer soon (<5years) for GPU programming. |
Voting closed, the winner is |
Currently there is no way to enforce a ruling on this since both clang-format and clang-tidy don't offer any related options. AFAIK there is a PR to clang-format in the pipeline but who knows when that will be incorporated. In any case we should decide on this as well so that we don't need to vote again once the option arrives.
The arguments for
const west
are found in the C++ Core Guidelines: https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rl-consttl;dr: It is more familiar to programmers and already present in a lot of code bases.
const west
examples:The arguments for
east const
are presented here: https://mariusbancila.ro/blog/2018/11/23/join-the-east-const-revolution/tl;dr: It is more logical and consistent.
east const
examples:VOTE
The text was updated successfully, but these errors were encountered: