Porting std.typecons to Phobos 3

monkyyy crazymonkyyy at gmail.com
Sun Nov 10 16:09:58 UTC 2024


On Sunday, 10 November 2024 at 01:16:40 UTC, Adam Wilson wrote:
> 
> I am intrigued by the concept of a fail-unsafe Option type, but 
> I'm not sure what the use case would be. When would you want to 
> explicitly do the unsafe thing? And could you not just achieve 
> the same result by putting `!` in front of the value presence 
> check?

I assume you got the terminology backwards, because computer 
science picked up the term failsafe to just mean a mechanism that 
detects edge cases.

Given a mechanism that detects an edge case, do you explode? If 
no, failsafe, if yes fail dangerous(or as the wokes call it "fail 
secure")

Given a sane range api with the ability to implement indexOf, if 
you fail to find the index you should return a 
`maybe!typeof(key)` assuming maybe is the premissive one, and 
option is the restrictive one; current countUntil lets you do 
math with the `-1` and maybe sometimes that just works, if you 
threw an exception in some code path youd need a seperate nogc 
version, you'd break some versions of code that just work etc.


More information about the Digitalmars-d mailing list