3 ms·
> which is 100% bug free define "bug free". In Python, I've been reimplementing monads recently. It's such a shame that Python still doesn't have Null/None pro
by behnamoh 3y ago
> which is 100% bug free
define "bug free". In Python, I've been reimplementing monads recently. It's such a shame that Python still doesn't have Null/None propagation. After each obtained result and before using it in the next chain, I have to run a series of sanity checks (is it Null or not, etc.) which should be resolved automatically by the language. Alas, most people don't care.
Something like this would be nice:
result =? foo(bar :? str)
meaning that foo should receive a str bar, but maybe bar is not str. Then foo should return something, but maybe it returns None (the =? part).
- unnouinceput 3y agoSomething like that would fail the code review at any large organization. Why? Because ternary operator is hard for maintenance purposes so the reviewer would simply ask to use if..else syntax instead. I gather you never worked in such organization.
- paganel 3y agoNot the OP and not a fan of ternary operations, but if programming were left to large organizations we would still be writing .asp pages. Which is to say that inovation happens only when you try to do stuff just a little different each time, so I’d say that code reviews as currently implemented at those big organizations is against long-term programming-related innovation.
- thewakalix 3y agoThat is not the ternary operator.
- wruza 3y agoBut following the setting of the gp comment, that operator would fail code review as well. Because the book of sacred rituals says so.
- benrutter 3y agoThis is an interesting idea- I'm not sure I understand it fully though. Do you have much luck with static type analysis? I find in Python, nothings ever certain, but mypy with good type hints solves a lot of these kind of None based shenanigans.
- behnamoh 3y agoI have heard about mypy but haven't seriously used it. Type hinting has helped a lot (basically you'll end up writing Python like it's Rust), but something like the Maybe monad (my example above) would reduce a lot of boilerplate.