2 ms·
"multiple return values with error codes looks pretty darn good" I'm a fan of making errors explicit, but I continue to find the use of effectively a product t
by dllthomas 11y ago
"multiple return values with error codes looks pretty darn good"
I'm a fan of making errors explicit, but I continue to find the use of effectively a product type (value and error) to return what is actually a sum type (value or error) to be ugly and error prone. Ideally, invalid states should be unrepresentable. In this case, both "value and error" and "no value and no error" are not. This is not good design.
- stcredzero 11y agoIdeally, invalid states should be unrepresentable. And clearly any language in which invalid states are representable is useless? Nice try, but nah. I like me some pure functions sometimes, but I'm not dogmatic about it.
- dllthomas 11y agoYour response is so bad I almost think you're trolling... Hoping (I think) not: "And clearly any language in which invalid states are representable is useless?" I did not call anything useless, much less the entire language. And I am the first to agree that trade-offs need to be made between a variety of considerations. But in this case, for the approach under discussion, I pointed out a design criteria that I find often important, that this approach is in flagrant violation of, while getting basically (perhaps literally) nothing in return toward any other design considerations. Either I missed things or that's just a bad decision. If you think it's the former, please engage me more constructively so that at least one of us can learn something. "Nice try, but nah." This is needlessly rude. "I like me some pure functions sometimes" This issue has zero to do with pure functions. "but I'm not dogmatic about it." Right, pointing out bad design can only come from a place of dogma. Never experience, never consideration, and never anything that could permit substantive discussion.