←back to thread

517 points bkolobara | 1 comments | | HN request time: 0.322s | source
Show context
aeve890 ◴[] No.45042188[source]
>The code will compile just fine. The Zig compiler will generate a new number for each unique 'error.*'

This is wild. I assume there's at least the tooling to catch this kind of errors right?

replies(3): >>45042403 #>>45042586 #>>45050319 #
arwalk ◴[] No.45042586[source]
The example is a bit dubious. Sure, it compiles just fine, because the author is not using errors properly in zig. Here, he uses the global error set with `error. AccessDenid`, and as stated, it compiles just fine because when you reach the global error set, it's integers all the way down.

If the author had written `FileError.AccessDenid`, this would not have compiled, as it would be comparing with the `FileError` error set.

The global error set is pretty much never used, except when you want to allow a user to provide his own errors, so you allow the method to return `anyerror`.

replies(3): >>45042666 #>>45043035 #>>45043562 #
empath75 ◴[] No.45043035[source]
All examples of this type come down to "the user made a mistake", but that is kind of the the entire point. It is not possible to make that mistake in rust.
replies(1): >>45043177 #
arwalk ◴[] No.45043177[source]
I'm not saying that zig has the same level of safety than rust, i'm just saying that grabbing a knife by the blade is not an argument for using a spoon.

The error presented in this example would not be written by any zig developer. Heck, before this example i didn't even knew that you could compare directly to the global error set, and i maintain a small library.

zig and rust do not have the same scope. I honestly do not think they should be compared. Zig is better compared to C, and rust is better compared to C++.

replies(3): >>45043283 #>>45043441 #>>45044284 #
jibal ◴[] No.45044284[source]
> The error presented in this example would not be written by any zig developer.

No True Scotsman fallacy. It was written by the Zig developer who wrote it.

replies(1): >>45046957 #
rmunn ◴[] No.45046957[source]
No True Scotsman is only a fallacy when it involves changing your definitions after counterexamples are presented. But it can also be insisting on a non-standard definition.

E.g., "No true Scotsman would hate haggis!" "You're wrong, my friend Angus hates haggis, and he's a Scotsman through and through." "Well, if he hates haggis, then he isn't a true Scotsman!"

The first speaker isn't changing his definitions, so he's not actually engaging in the fallacy. Rather, he's insisting on his own idiosyncratic definition of what standards you must meet to be considered a "true" Scotsman, and insisting that Angus doesn't meet his standard.

But that's enough digression on "No True Scotsman". We now return you to your regularly-scheduled arguing over code. :-)

replies(1): >>45048298 #
jibal ◴[] No.45048298[source]
> is only a fallacy when it involves changing your definitions after counterexamples are presented

That is false.

Edit: The fact is that we have the counterexample: the piece of code written by a zig developer who somehow isn't actually a zig developer. Where the counterexample comes from, who presents it, and when isn't relevant to whether this is a fallacy. The Wikipedia article overstresses the order of things, but that is never an issue with a fallacy. There are thousands upon thousands of examples where, e.g., someone claims that people aren't Christians because they don't follow Christ's teachings and that claim is called out as a No True Scotsman fallacy--it implicitly redefines what "Christian" is for the sake of denying that a Christian actually is a Christian, in order to preserve some claim of some virtue of Christianity in the face of clear evidence to the contrary.

replies(2): >>45048443 #>>45048666 #
1. rmunn ◴[] No.45048443[source]
Then you might want to update the Wikipedia article which claims that it's a fallacy "in which one modifies a prior claim in response to a counterexample by asserting the counterexample is excluded by definition", citing three links to support that: https://iep.utm.edu/fallacy/, http://www.fallacyfiles.org/scotsman.html, and https://archive.org/details/godphilosophy0000flew/page/104/m....

To say "No true Scotsman would dislike haggis" is to assert "If A, then B": If you are a true Scotsman, then you will like haggis. The response "Angus doesn't like haggis" is asserting "not B". To which the response "therefore he's not a true Scotsman" is asserting "not A". But "if A, then B" logically implies "if not B, then not A". Therefore when the person's definitions don't change, *it is not a fallacy*. It might be wrong — his definition of a "true" Scotsman might be a false premise — but the conclusion logically follows from the premise, so it is not a fallacy.