|
Could God make a type so optional that even He couldn't reify it?
|
# ? Dec 12, 2023 17:05 |
|
|
# ? Jun 8, 2024 06:17 |
|
Volte posted:None and null aren't the same thing.
|
# ? Dec 12, 2023 17:07 |
|
leper khan posted:If they happen sooner, you're converting from a nullable or reference type to a non-nullable value-type. Checking for a value has similar semantics and failing to do that in both cases throws an exception.
|
# ? Dec 12, 2023 17:26 |
|
Volte posted:Forget the word "null", it's distorting your viewpoint. Option is effectively a list that can have either zero or one element in it, and as a result you can basically use all the nice patterns that you can use with lists (and a few others that come from the zero-or-one property too). Null specifically means an invalid pointer, and it is sometimes (mis)used to represent the "empty list" case, but None and null aren't the same thing. Null is the absence of value. The concept isn't unique to pointers.
|
# ? Dec 12, 2023 19:09 |
|
Having Optional in your statically typed language has a bigger benefit: the absence of value is now an invalid value for every type that isn't Optional. The problem with null is when the language lacks the ability to stipulate non-nullability for reference types. If nothing is Optional, everything is. Obviously, none of this applies to dynamically typed language, where everything can be anything or nothing all the time. Bongo Bill fucked around with this message at 19:23 on Dec 12, 2023 |
# ? Dec 12, 2023 19:20 |
|
RPATDO_LAMD posted:I took an elective "number theory and cryptography" course where the professor was in that same "I don't care about what language you use just get the math parts right" stance. I had a class like that, and the professor said the same thing about languages. Then I sat down for the final and there was a question that started with "Write a Fortran program that..." I wrote down something like "There's no way I'm doing this in Fortrain, here's how to do it in C..." No idea what grade I got.
|
# ? Dec 12, 2023 19:37 |
|
leper khan posted:Null is the absence of value. The concept isn't unique to pointers. leper khan posted:Horror from the thread and all, but I never understood the appeal of option types. Doesn't give any more information than a pointer.
|
# ? Dec 12, 2023 21:28 |
|
Volte posted:Option is effectively a list that can have either zero or one element in it *In a language where Optional is implemented in a useful way (i.e. not Java)
|
# ? Dec 13, 2023 05:03 |
|
making every method return an array since i heard about "monads" once
|
# ? Dec 13, 2023 06:53 |
|
monads mo problems
|
# ? Dec 13, 2023 09:14 |
|
i have zero or more problems
|
# ? Dec 13, 2023 09:22 |
my problems may be undefined or absent depending on the language i am using
|
|
# ? Dec 13, 2023 15:19 |
|
Polio Vax Scene posted:my problems may be undefined or absent depending on the language i am using My problems are severe but not representable.
|
# ? Dec 13, 2023 15:24 |
|
redleader posted:making every method return an array since i heard about "monads" once same but IO
|
# ? Dec 13, 2023 15:36 |
|
People who like Haskell so they recreate Haskell in every language they use are a thing, unfortunately.
|
# ? Dec 13, 2023 21:41 |
|
Doc Hawkins posted:i have zero or more problems
|
# ? Dec 13, 2023 22:46 |
|
If it has flatMap, it's a monad. It really is that simple. People are just really bad at explaining it.
|
# ? Dec 13, 2023 22:58 |
|
flatMap is just the worst name. Who came up with that? We already had better names before that caught on in the bad languages.
|
# ? Dec 14, 2023 00:02 |
|
bind is arguably a worse name for being so opaque, >>= being even more so at least for most people, the first monad they'll meet is List otherwise known as the non-deterministic choice monad so thinking of the operation as "map over each element, producing a nested list and then flatten it down" isn't totally unreasonable imo
|
# ? Dec 14, 2023 00:15 |
|
"flatten" being the operation that takes M<M<T>> and turns it into M<T> makes sense generally, and "flatMap" being "map, then flatten" also makes sense.
|
# ? Dec 14, 2023 00:20 |
|
When you want to name an operation in a highly abstract concept, naming it after its behaviour in a specific instance of that concept seems more likely to muddle than clarify. Just don't mention monads as a concept if you are not ready to deal with the generality.
|
# ? Dec 14, 2023 00:22 |
|
Athas posted:When you want to name an operation in a highly abstract concept, naming it after its behaviour in a specific instance of that concept seems more likely to muddle than clarify. Just don't mention monads as a concept if you are not ready to deal with the generality. yeah, call it "monadize" or similar or SelectMany
|
# ? Dec 14, 2023 01:20 |
|
monads are a scam invented by big functional to sell more functions
|
# ? Dec 14, 2023 01:24 |
|
repiv posted:monads are a scam invented by big functional to sell more functions we haven't had a new thread title in a while...
|
# ? Dec 14, 2023 09:25 |
|
repiv posted:monads are a scam invented by big functional to sell more functions
|
# ? Dec 14, 2023 22:06 |
|
Big Lambda.
|
# ? Dec 14, 2023 23:04 |
|
OddObserver posted:Big Lambda. Computational complexity? That's just a lie you've been told by Big O
|
# ? Dec 14, 2023 23:35 |
|
Look, we've all got plenty of experience with Big O lies, okay, don't rub it in
|
# ? Dec 14, 2023 23:39 |
|
OddObserver posted:Big Lambda. Black Mesa?
|
# ? Dec 15, 2023 08:52 |
|
https://twitter.com/yiningkarlli/status/1736300787704426780
|
# ? Dec 18, 2023 04:14 |
|
deliberately writing bad code and then getting salty at visual studio for just say "nah"
|
# ? Dec 18, 2023 04:54 |
|
I agree with the compiler on this one.
|
# ? Dec 18, 2023 05:32 |
|
I love that the compiler docs for that "limitation" just outright tells you to refactor your code.
|
# ? Dec 18, 2023 05:36 |
|
can probably "fix" it with a single pair of braces
|
# ? Dec 18, 2023 06:24 |
|
That limitation hints at a very weird representation inside the compiler, though. Also, when you have code like that, it is usually because it is generated, and then it can be very annoying to run into those arbitrary restrictions. I also remember MSVC having a fairly low limit on the length of string literals (although still longer than sane for human written code).
|
# ? Dec 18, 2023 08:09 |
|
I don’t think clang has a limit there that we enforce, but I wouldn’t be surprised if the practical limit is relatively low just because it’s a recursive position in the grammar and it’s natural to handle them in a million places in the compiler with recursive calls. We regularly have to chase down new bits of code that blow out the stack because they use recursion on e.g. switch cases instead of special-casing them to iterate.
|
# ? Dec 18, 2023 08:38 |
|
That's an improvement over the compiler I was using in the early-mid 90s as a student which topped out way below that.
|
# ? Dec 18, 2023 16:09 |
|
I had to check the date on this tweet because I discovered the same msvc “limitation” in 2009ish. I think it had something to do with automated code generation for a JNI bridge.
|
# ? Dec 18, 2023 16:32 |
|
Athas posted:Also, when you have code like that, it is usually because it is generated, and then it can be very annoying to run into those arbitrary restrictions.
|
# ? Dec 18, 2023 17:16 |
|
|
# ? Jun 8, 2024 06:17 |
|
ExcessBLarg! posted:I'm struggling to think of a good example of having 100+ "else if" blocks even for generated code. Surely it could be converted to some kind of dispatch mechanism, or at least convert the conditional tests into a tree form. I want to write my code generator in 5 minutes, and generating additional elif blocks is easy.
|
# ? Dec 18, 2023 17:34 |