4 ms·
"let" is more elegant IMO.
by lkjlakjsdlfkj 9y ago
"let" is more elegant IMO.
- coldsauce 9y agodo you mean the word itself? or some implementation detail is more elegant?
- saagarjha 9y agolet as a drop-in replacement for var, or something semantically different?
- ajkjk 9y agoI always found 'let' to be such a strange name. What on earth is appealing about it? The usual variable declaration syntax is <type> <name>; it's not a stretch to imagine the type as 'var', a catchall type. But 'let'? Let is a verb; it should be in a place where functions, not types, go. It makes sense in "let x in {}" type expressions, and it kinda makes sense in Lisp, but I don't see any argument for it in a C-like language.
- cryptonector 9y agoIt's math-y. As in "let n be a natural, ...".
- MichaelGG 9y ago>It makes sense in "let x in {}" type expressions Without jumps, all code can be rewritten to be a series of "let x = ... in <expression>" The fact Java has statements instead of everything being expressions is a design flaw and should be rectified not glorified.
- kazinator 9y ago> I don't see any argument for it in a C-like language. The inventor of the C-like languages B and NB (which then inspired C) agreed and used the more intuitive auto. { auto x = 1; /* x is implicitly an integer */ } Now it's back in vogue in the C-like language C++. It doesn't mean "automatic storage", though.