5 ms·
Nothing is preventing the code from returning both at the same time. I've seen code (including in the standard library) that returns both an error and a return
by za3faran 3y ago
Nothing is preventing the code from returning both at the same time. I've seen code (including in the standard library) that returns both an error and a return value. In a language with disjoint unions, such cases would be encoded properly.
- preseinger 3y agoconvention prevents it and in the case where returning both is OK, then documentation makes that clear this is not difficult
- aniforprez 3y agoConvention in no way prevents anything. Convention is simply that. People are free to not follow convention when nothing is enforcing it. You frequently see juniors, who may be brand new to the language, making mistakes with conventions. If I'm supposed to depend on the vagaries of some accepted standard that is only documented in text then it is less than useless in the real world
- preseinger 3y agoif we say a language "addresses" a given concern, is it necessary that this is accomplished in the compiler, and that the rules for that concern, whatever they are, are enforced at compile-time? (spoiler: no)
- aniforprez 3y agospoiler: yes If the language "addresses" it by convention then it is not addressing it at a language level at all
- preseinger 3y ago"the language level" is not only what is defined and enforced by the compiler but i'm sure i won't convince you of anything here, so good luck to you
- za3faran 3y agoWe all know that documentation always 100% matches the behavior of the code :-)