[Bug 29004] FrozenArray only provides shallow immutability

https://www.w3.org/Bugs/Public/show_bug.cgi?id=29004

--- Comment #5 from Boris Zbarsky <bzbarsky@mit.edu> ---
Since the array is frozen, the platform can't grow/shrink/change it either; if
the list changes it needs to start returning a new object.  So it's not that
the platform is doing anything author code can't do (apart from returning the
object to start with).

The idea of freezing is to not have author code accidentally change the array,
leading to other author code getting bogus values.  For some APIs, where there
is probably only one consumer on the page for the object in question, maybe
this doesn't matter.  For other APIs, e.g. anything on Window or Document or
Navigator or any other per-page singleton, it's easy to end up with multiple
unrelated scripts using the same array.

Note that nothing prevents a spec from defining an API which returns an
unfrozen array.  You use the "object" return value and define all your behavior
in prose.  The point of FrozenArray is to nudge people towards one particular,
safe-by-default, pattern, but if someone feels a strong need to do something
different they always can.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Received on Friday, 31 July 2015 18:26:54 UTC