A great way to lower memory cost when reusing a list across thousands of atoms is to keep it in one place, and reference that everywhere. However, this opens up the potential for a developer to accidentally mutate the list, which will mess up everything else.
It would be nice to be able to freeze a list, causing a runtime error if the list was mutated.
This could just be a shallow freeze, and doesn't need to try to do crazy stuff like make the atoms inside immutable or whatever, just block insert/remove/update/etc. If a function was provided to check if a list is frozen, a developer could also make their own deep freeze proc.
Ideally there would be no way to "thaw" a list.
table.freeze, table.isfrozen in Luau: https://luau-lang.org/library#table-library
Sep 23, 12:12 am