lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, Jun 10, 2019 at 3:27 PM Dibyendu Majumdar <mobile@majumdar.org.uk> wrote:
On Mon, 10 Jun 2019 at 21:21, Coda Highland <chighland@gmail.com> wrote:
> However, non-assignable variables are pretty useful. There are some compiler optimizations that can happen when you know a variable is read-only, and of course asserting that something is read-only can help avoid programming mistakes.
>
> There's also no real reason the same qualifier couldn't be used for both. It would just be part of the optimization: if a compiler can statically determine the value of an _expression_, it can replace it with the result of that _expression_, and being read-only and initialized with a literal is a good way to ensure that the value can be statically determined.
>

Which leads me to a second thought about the syntax.
If you wanted to declare a bunch of constants in one go, it might be
nicer to be able to do it with a single annotation, rather than per
variable annotation.

As I mentioned in the other thread, that's sort of getting into bikeshedding. Yes, it would be nice to be able to do that, but on the other hand it would also be nice to specify a mixed set of annotations in a single statement instead of needing a separate statement for each type of annotation. Roberto had asked you how you intended to resolve that in that thread.

/s/ Adam