Re:Adding Syntax to the CPython Interpreter
by steveklabnik on Saturday October 19, 2024 @10:41AM
(#41888024)
Option is already a lang item, so that would t be an issue. I don’t know what the actual underlying reason is, or if it was ever even proposed.
Re:Adding Syntax to the CPython Interpreter
by bbb651 on Saturday October 19, 2024 @04:44PM
(#41890649)
I meant more than it already is, I referenced this: https://stackoverflow.com/a/43339003. I do think it would be neat but it's niche enough to not be worth the non-obvious behavior of boxing with `Option`, e.g. you might forget an `else { ... }` and get complex type errors.
Rust for example has a solution for this in std, there's a `bool::and_some` method (and `bool::then` that takes a closure to avoid eagerly evaluating the value), but `if { ... }` isn't an expression like `if { ... } else { ... }` is, probably to avoid coupling the language to `Option`.