Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEW] use native bool type in Valkey #413

Open
PingXie opened this issue May 1, 2024 · 7 comments
Open

[NEW] use native bool type in Valkey #413

PingXie opened this issue May 1, 2024 · 7 comments

Comments

@PingXie
Copy link
Member

PingXie commented May 1, 2024

This feels almost like a separate major decision since it's so deeply rooted in this code base. We have atomics and other C99 and later features, but not bool and C++ comments. 馃槃

I'd like to hear arguments against adding it though. It's part of C nowdays and it's odd to have a rule that forbids it.

Originally posted by @zuiderkwast in #245 (comment)

@madolson
Copy link
Member

madolson commented May 1, 2024

What's a c++ comment?

@madolson
Copy link
Member

madolson commented May 1, 2024

The only thing I don't like about bool is that:

int isTrue() { return 1 }

is not the same as

bool isTrue() { return true}

Since a bool is only 1 byte. We have actually had production outages because of that mistake at AWS, because we internally use bool in various places, and people didn't understand the difference.

More generally, I prefer the code to more or less all use the same conventions. It's much more important to me to be consistent, since the more we diverge the more folks will poke in and say they want to do something else because that is the way that they like it.

@zuiderkwast
Copy link
Contributor

What's a c++ comment?

// "C++ style" line comments are valid in C99

@zuiderkwast
Copy link
Contributor

Let's keep these conventions then. Are they actually written down anywhere?

@madolson
Copy link
Member

madolson commented May 2, 2024

What's a c++ comment?

I've never heard these be called C++ comments, always single line comments. That just might be because I never write C++ code though :D

@zuiderkwast
Copy link
Contributor

They're coming from c++ originally i believe.

https://en.cppreference.com/w/c/comment

@hwware
Copy link
Member

hwware commented May 2, 2024

I remember in very old C, there is no bool type, it is not like C++, which has built-in data type boolean.
After C99, C import bool type, but in low level, i think it need to be converted into integer zero or non-zero value.
Thus, i think in valkey, we do not need to import #include <stdbool.h>.

Personally, I have C++ experience. I still remember when I read redis code initially, because Redis is written by pure C language, I am confused by some C syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants