Reminds me of the '$' operator in Haskell - it lowers the precedence of function application, basically being an opening parenthesis that's implicitly closed at the end of the line.
1,217 karma · joined November 21, 2020
Reminds me of the '$' operator in Haskell - it lowers the precedence of function application, basically being an opening parenthesis that's implicitly closed at the end of the line.
The distinction between is one I've mentally adopted in other languages like Python as well. For personal projects I like to use single quotes for 'symbols' and double quotes for "strings", e.g.:
add_label(text="Hello World!", align='center')
Does anyone else do something similar? var4 = (var1==1)*(var2+var3) | (var1==2)*(var2-var3) | ...
Of course this is basically the slowest possible option, but it might work as a starting point for a general-purpose optimizer to find a faster solution. If it doesn't, this will likely compile to conditional move instructions.It might help if you replace the comparison and multiplication with an equivalent expression made from bitwise operations, but I believe most compilers already know how to do this transformation.
Logging does seem like a very similar case to debugging, only that you expect to leave it on in production. On the other hand an implicit Database effect kind of defeat the point of an effect system.
I think the key is that Debug and Logger effects don't really affect the rest of the code - if you remove all debug/log statements, the only thing that changes is the debug/log output (and slightly faster execution probably).
You also don't think about dollars differently than other units, just because the sign goes before the number.
dough = mix(flour, water, sugar, butter)
dough.knead()
dough = dough.add(eggs)
cookies = dough.divide(12)
cookies = bake(temp=450, minutes=12)
Might be more verbose, but definitely readable.The author doesn't want manual memory management, but still decides to go with Rust.
There's actually two different ways that Rust types can always be discarded: mem::forget and mem::drop. Making mem::forget unsafe for some types would be very useful, but difficult to implement without breaking existing code [1].
Btw, you are correct with linear types - Affine types allow discarding (like Rust already does).
Your comparison to placebo is very apt: Giving medication to a patient (vs not giving anything) causes them to get better, but it might be the "giving a pill" part instead of the "ingesting medication" part that matters.
For this discussion it makes sense call the "mass" of a field "stiffness" instead, since it's not known a priori that it corresponds to particle mass.