Post AddJTzMtJKudwESBxA by KeithC@toot.community
(DIR) More posts by KeithC@toot.community
(DIR) Post #Add0gwxXgDe56R417w by KeithC@toot.community
2024-01-07T18:35:59Z
0 likes, 0 repeats
Having dropped #python for its insane use of the amount of whitespace as semantically relevant, I thought I'd look at #kotlin. Then I came across this line in the docs: "Read-only local variables are defined using the keyword val". If they are read-only they are NOT variables. This might just be the author of that entry, but it occurs elsewhere. It is not enough to stop me from looking into the language deeper, but it is pretty sloppy.
(DIR) Post #Add0gyDsywJT1PiaEy by alexelcu@social.alexn.org
2024-01-08T06:56:07Z
0 likes, 0 repeats
@KeithC Variables are symbolic names bound to memory locations at runtime. As far as naming goes, mutability isn't required. The requirement is the separation between the name and the memory location.Even with your intuition, `val` in #Kotlin creates variables that cannot change during the lifetime of the variable, but the values can be different b/w lifetimes.Naming them “values” would be incorrect, too, as values refer to the actual objects stored in memory. Also see r-value vs l-value.
(DIR) Post #Add3FraVqIhiUH4Ffc by alexelcu@social.alexn.org
2024-01-08T07:24:52Z
0 likes, 0 repeats
@KeithC Note that in math or lambda calculus, the variables are basically the function parameters.Lambda calculus may bring clarity, as the variables are basically the symbols needing substitution for β-reduction. And even the “named constants” get defined as variables in a function definition that's immediately applied. Hence, named constants in pure lambda calculus are variables, too.
(DIR) Post #AddJTzMtJKudwESBxA by KeithC@toot.community
2024-01-08T10:26:40Z
0 likes, 0 repeats
@alexelcu good explanation, thank you