valkey-io / valkey

A new project to resume development on the formerly open-source Redis project. We're calling it Valkey, since it's a twist on the key-value datastore.

Home Page:https://valkey.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[NEW] use native `bool` type in Valkey

PingXie opened this issue · comments

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)

What's a c++ comment?

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.

What's a c++ comment?

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

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

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

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

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

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.