

I agree. So if None is a valid input we should check it first, and then check if the length is zero. In this situation, we see a type error only if the programmer screwed up and everything is explicit
I agree. So if None is a valid input we should check it first, and then check if the length is zero. In this situation, we see a type error only if the programmer screwed up and everything is explicit
I don’t really understand the point about exceptions. Yeah “not foo” cannot throw an exception. But the program should crash if an invalid input is provided. If the function expects an optional[list] it should be provided with either a list or None, nothing else.
Passing None to a function expecting a list is the error…
Well, in your case it is not clear whether you intended to branch in the variable foo being None, or on the list being empty which is semantically very different…
Thats why it’s better to explicitly express whether you want an empty collection (len = 0) or a None value.
I really dislike using boolean operators on anything that is not a boolean. I recently made an esception to my rule and got punished… Yeah it is skill issue on my part that I tried to check that a variable equal to 0 was not None using “if variable…”. But many programming rules are there to avoid bugs caused by this kind of inattention.
I had never heard of Democracy Manifest before coming to lemmy. I am loving this subculture in strad of reddit’s
40-14 is also off by half a year, dang
Use a spoon/fork to direct the flow, the liquid will follow the surface of the spoon, not that of the container
But what does that mean?
Great article I think. I don’t have a lot of experience in zig, but I feel like it’s just a better version of C. More specifically, C with a more modern synthax, better defined behaviour, better error handling. As the author highlights it, using the comptime and reflection to make generics can easily become a footgun and make the code messy. But hey, having the option to make generic code is still better than C.
I wish Switzerland had chosen Gripen over the F35 :'(
I can follow you around and make sure that your beer, bread, wine, meat and sausages are edible… To ensure you don’t get food poisoning ofc!
Fun that this is brought up at this time. Just a few days ago I tried to program the programable thermostat of my grandma. I am convinced that the thing has a bug making it impossible to select a schedule… It has a lot of buttons and a screen, but due to a minuscule mistake in the interface it’s no better than a temperature slider…
Allow me an argument by Doctor Who: https://www.youtube.com/watch?v=BJP9o4BEziI
You can use violence, but when does it end, and what makes you think you are going to end up better off?
Does a microkernel matter for anyone but nerds? Maybe companies that make variants of the OS?
To be fair, “they” could probably train AI on Lemmy data, they just won’t ask for permission and won’t be charged for it
If all major APIs use SPIR-V, does it mean that it could become the ISA of some GPUs? Like that time someone made some hardware that executed Java bytecode directly?
I dislike treating None as an equivalent for the empy list, but that does not further the discussion…
I hurt myself in confusion while reading the second quote. Is it the right quote? (also, nazi (relating to the nsdap) is probably not the right word, did you mean fascist?)