zlacker

[return to "Nimony (Nim 3.0) Design Principles"]
1. mwkauf+M2[view] [source] 2025-12-02 01:00:22
>>andsoi+(OP)
Big "college freshman" energy in this take:

  I personally prefer to make the error state part of the objects: Streams can be in an error state, floats can be NaN and integers should be low(int) if they are invalid (low(int) is a pointless value anyway as it has no positive equivalent).
It's fine to pick sentinel values for errors in context, but describing 0x80000000 as "pointless" in general with such a weak justification doesn't inspire confidence.
◧◩
2. ratmic+sIb[view] [source] 2025-12-05 13:10:09
>>mwkauf+M2
Without the low int the even/odd theorem falls apart for wrap around I've definitely seen algorithms that rely upon that.

I would agree, whether error values are in or out of band is pretty context dependent such as whether you answered a homework question wrong, or your dog ate it. One is not a condition that can be graded.

◧◩◪
3. umanwi+Q1c[view] [source] 2025-12-05 14:48:25
>>ratmic+sIb
What is the "even/odd theorem" ?
◧◩◪◨
4. ratmic+U5c[view] [source] 2025-12-05 15:07:10
>>umanwi+Q1c
that all integers are either even or odd, and that for an even integer that integer + 1 and - 1 are odd and vice versa for odd numbers. That the negative numbers have an additional digit from the positive numbers ensures that low(integer) and high(integer) have different parity. So when you wrap around with overflow or underflow you continue to transition from an even to odd, or odd to even.
◧◩◪◨⬒
5. xigoi+a9c[view] [source] 2025-12-05 15:22:01
>>ratmic+U5c
If you need wraparound, you should not use signed integers anyway, as that leads to undefined behavior.
◧◩◪◨⬒⬓
6. umanwi+2cc[view] [source] 2025-12-05 15:34:06
>>xigoi+a9c
Signed overflow being UB (while unsigned is defined to wrap) is a quirk of C and C++ specifically, not some fundamental property of computing.
◧◩◪◨⬒⬓⬔
7. xigoi+Gcc[view] [source] 2025-12-05 15:36:30
>>umanwi+2cc
Nim (the original one, not Nimony) compiles to C, so making basic types work differently from C would involve major performance costs.
[go to top]