tkoola
tkoola
This principle is probably formalized or named by someone, but got bitten again by it: one should always make “no value” clearly separate from “zero/nil/empty/first enum value”. Specifically in C, enums should not use “0” as a valid value I’d be able to implement a new feature in fe... blog.timokoola.com
|
Embed
Progress spinner
In reply to
a_seagull_story
a_seagull_story

@tkoola You have my sympathies. The rule you quoted seems like two rules; am I reading it right? 1. "None" values shouldn't be zero and 2. Valid values shouldn't be zero. I don't use zero for valid values but I do use zero (the first enum slot) as the "None" value. What's your take?

|
Embed
Progress spinner
tkoola
tkoola

@a_seagull_story I am getting more careful even with (b). While I am usually going with NONE being zero, I try to figure out if NONE will always have the same code paths as ”uninitialized”. I try to figure if that is the case

|
Embed
Progress spinner
a_seagull_story
a_seagull_story

@tkoola Sounds good to me. I like it when we have these kind of chats. :)

|
Embed
Progress spinner