On Thursday, 16 January 2025 at 19:37:36 UTC, Basile B. wrote:
> On Thursday, 16 January 2025 at 19:13:38 UTC, monkyyy wrote:
> On Thursday, 16 January 2025 at 19:02:05 UTC, Basile B. wrote:
> [...]
- add a error code system to the range api
- damn the consequences have fail safe functions(1/0==int.max)
- store errors and extra control flow in my
innate
pattern
- nullable everywhere, range functions can react to nullable elements
- preallocate some space for exceptions, cap the size of exception objects(assuming this is about betterc)
I dont see how that helps to abort when an error happens "in between the chain" let's say.
aborts are bad; hottake; nullables are far far better pattern
But 3 and 5 could be the same "bad goto" as exceptions with compiler help or some truly awful raw asm
3 could also abort on error with lib design, but that would be very ugly
nullable!int inverse(int i){
if(i==0){return null;}
return 100/i;
}
[2,0,5,4].map!inverse.sort==[null,20,25,50];
Could just exist, theres one of them eagerness vs lazyness tradeoffs here between eager exceptions and lazy nullables; Im very much in favor of the later and never use exceptions as intended(when phoboes throws, make an hack to make it go away)