From 4e839ca0fd9295a33d1ca10ab275c2456a1f1ae4 Mon Sep 17 00:00:00 2001 From: Dekkonot <4625546+Dekkonot@users.noreply.github.com> Date: Thu, 11 Nov 2021 13:09:24 -0800 Subject: [PATCH] Adjust Javascript alternative --- rfcs/syntax-constant-variables.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rfcs/syntax-constant-variables.md b/rfcs/syntax-constant-variables.md index 9c89fb2e..9aba95e8 100644 --- a/rfcs/syntax-constant-variables.md +++ b/rfcs/syntax-constant-variables.md @@ -65,7 +65,7 @@ The semantics of the proposed implementation may be confusing to people. Constan Python does not have constants and relies upon convention to indicate what is and isn't a constant. This is what Luau currently does. This has the drawback of making users trust that a 'constant' isn't ever changed, which isn't always easy to verify. It is however very practical provided every user obeys the suggestion of not modifying constants. -JavaScript *does* have constants that are declared in a similar manner (`const foo = bar;`) but have a caveat: constants are not immutable, they are effectively just read-only variables. This is basically worse than nothing and not worth the parsing and runtime cost since it comes with almost none of the benefits and all of the downsides. Most interpreted languages that have constants are either this or worse (Ruby, as an example, doesn't even make the variable readonly) +JavaScript *does* have constants that are declared in a similar manner (`const foo = bar;`) but have a caveat: constants are not immutable, they are effectively just read-only variables. This is basically the same as this proposal but without freezing tables, meaning it has all of the drawbacks of this implementation but relatively few advantages. Most interpreted languages that have constants are either this or worse (Ruby, as an example, doesn't even make the variable readonly). Constants could be limited to primitives and perhaps tables, guaranteeing that they are real constants and potentially allowing for compiler optimizations that aren't possible with arbitrary data type support. The usability limitation prevented this from being seriously considered, as not supporting userdata is considered to be a non-starter.