BOOL datatype feels weird #174
Unanswered
lucasbalieiro
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
if we read the documentation for the BOOL datatype, it states:
I understand the intent: only the least significant bit determines the boolean value, leaving the remaining bits available for potential future use as flags.
However, this design seems inconsistent with how flags are handled elsewhere in the protocol.
For example, in messages that explicitly use flags, such as
SetupConnection, the spec uses aU32, with each bit clearly defined as a flag:sv2-spec/03-Protocol-Overview.md
Line 250 in aadcb32
From a user perspective, this is much clearer. Using a
BOOLboth as a boolean and as a potential future flag container adds cognitive overhead without an obvious benefit.A simpler and more consistent approach would be one of the following:
BOOLstrictly as a boolean (0 = false, non-zero = true), orThe current
BOOLapproach also introduces unintuitive edge cases. For example:2(0b00000010) →false3(0b00000011) →true4(0b00000100) →falseWhile this behavior is correct per the specification, it is surprising for a type named
BOOL.I looked for historical context in the repository, but the earliest reference I found was during the migration from Google Docs:
#1
If there is a stronger rationale behind this design choice, I may be missing it. As it stands, the current design appears to favor hypothetical future flexibility over clarity and consistency.
All reactions