Why make it complicated?
-
Made with KolourPaint and screenshots from Kate (with the GitHub theme).
I've always wondered where all this 'let' business started
-
I've always wondered where all this 'let' business started
wrote on last edited by [email protected]It's commonly used in math to declare variables so I assume programming languages borrowed it from there.
-
You're encoding more information in the typescript one. You're saying it's a string that will get updated.
Yeah, it's explicitly distinct from
const a: String
which says it won't change, andvar a: String
, which means this is legacy code that needs fixing. -
You're encoding more information in the typescript one. You're saying it's a string that will get updated.
You aren't though. In most languages that use the latter declaration you would prefix the declaration with final or const or the like to specify it won't be updated.
-
It's commonly used in math to declare variables so I assume programming languages borrowed it from there.
BASIC uses (used?) it to declare variables. (I don't know if earlier languages did.)
Not that that's a reason for other languages to copy it.
-
BASIC uses (used?) it to declare variables. (I don't know if earlier languages did.)
Not that that's a reason for other languages to copy it.
wrote on last edited by [email protected]Doesn't Basic use
Dim a As String
? -
Made with KolourPaint and screenshots from Kate (with the GitHub theme).
python:
a: str = 1
-
I've always wondered where all this 'let' business started
More than you'd ever want to know: https://en.m.wikipedia.org/wiki/Let_expression
-
Yeah, it's explicitly distinct from
const a: String
which says it won't change, andvar a: String
, which means this is legacy code that needs fixing.If there's only two options you only need one keyword
-
Doesn't Basic use
Dim a As String
?wrote on last edited by [email protected]Older variants used DIM for arrays and LET for other variables. DIM was originally called that because it was setting the dimensions of the array.
In modern BASIC variants, DIM has become a backronym: "declare in memory".
-
Made with KolourPaint and screenshots from Kate (with the GitHub theme).
Can we talk about PHP functions with typehints too?
public static function foo(): string {
Practically every other language with similar syntax does this instead:
public static string foo() {
-
Can we talk about PHP functions with typehints too?
public static function foo(): string {
Practically every other language with similar syntax does this instead:
public static string foo() {
TIL PHP has statics.
Also, does PHP actually enforce the type declarations? I'd assume it would but knowing PHP...
-
TIL PHP has statics.
Also, does PHP actually enforce the type declarations? I'd assume it would but knowing PHP...
It enforces scalar types (string, int, etc) at runtime if you enable strict mode. There's also static analysis tools like PHPStan and Psalm that will flag issues at build time.
-
Older variants used DIM for arrays and LET for other variables. DIM was originally called that because it was setting the dimensions of the array.
In modern BASIC variants, DIM has become a backronym: "declare in memory".
TIL Backronyms and cuil BASIC technicalities
Much obliged all -
python:
a: str = 1
And then assign an int to a string just to mess with the interpreter.
-
Made with KolourPaint and screenshots from Kate (with the GitHub theme).
First time i used let it was to inline variable declaration with assignment . Can’t remember the language.
-
Older variants used DIM for arrays and LET for other variables. DIM was originally called that because it was setting the dimensions of the array.
In modern BASIC variants, DIM has become a backronym: "declare in memory".
Even older variants required both a let to declare the variable and a dim to set its size.
I remember a
REDIM
command, but I really can't remember what basic it's from. -
Made with KolourPaint and screenshots from Kate (with the GitHub theme).
Good, now invent a keyword for variables you don't want to declare the type. And now that you have a mix of keywords and identifiers on the same place, you can never update your language again.
Also, make the function declarations not use a keyword too, so you get the full C-style madness of code that changes meaning depending on what libraries you import.
-
More than you'd ever want to know: https://en.m.wikipedia.org/wiki/Let_expression
I doubted you until I got about halfway through this whole page. I concede tho--you are most correct lol
Still a decent read and for that I thank you -
Made with KolourPaint and screenshots from Kate (with the GitHub theme).
wrote on last edited by [email protected]Because sometimes that
let
can be replaced by other things likeconst
. Which can be managed statically by the machine and not by my (imperfect) ability to know if it's mutated or not