News for hackers. Stuff that matters.
Re:Never trust a system that seems to be working by jallmann on Monday October 17, 2022 @05:16PM (#33239601)
Also issue with golang (+ protobufs) where you can't distinguish a populated zero value from the default "not present" value.
Re:Never trust a system that seems to be working by kortex on Monday October 17, 2022 @05:59PM (#33240060)
This drives me absolutely bonkers. We had a situation in a machine learning context where we should have been treating the output of a detector as NaN (it was deliberately opting out), but instead it was falling back to zero.

Last I checked (this was years ago) the way to deal with this is to wrap it in a sub-message (which are actually nullable), which is just kinda gross.

Re:Never trust a system that seems to be working by krackers on Monday October 17, 2022 @06:45PM (#33240476)
I thought proto3 has support for optional scalar fields now (https://github.com/protocolbuffers/protobuf/releases/tag/v3....), and proto2 always had it
Re:Never trust a system that seems to be working by bazoom42 on Monday October 17, 2022 @06:37PM (#33240401)
Thats why JavaScript has both undefined and null!
Re:Never trust a system that seems to be working by deely3 on Tuesday October 18, 2022 @02:58AM (#33243899)
Do we really need to differentiate between undef and null?
Re:Never trust a system that seems to be working by bazoom42 on Tuesday October 18, 2022 @01:54PM (#33251341)
Not necessarily, but it does allow a level of robustness to be able to distingish between values which have deliberately been assigned null, and values which have not been initialized correctly.
Re:Never trust a system that seems to be working by mananaysiempre on Tuesday October 18, 2022 @05:40AM (#33244924)
Lua does fine with only a nil, although it gets a tad annoying when you actually want to store a nil value in an array and end up creating a hole instead. (Arguably, the solution to that problem is to use your own marker object and not a nil when you need some sort of unspecified or default value which is not a literal absence of one.)
Re:Never trust a system that seems to be working by hardware2win on Tuesday October 18, 2022 @02:59AM (#33243905)
C# linqs method - first or default has the same problem
Re:Never trust a system that seems to be working by int_19h on Wednesday October 19, 2022 @05:11PM (#33267994)
The method itself just uses the default value of the corresponding type. If you have a sequence of ints, and you cast it to Nullable<int> first before applying FirstOrDefault, then you can distinguish between null and 0.