W3C home > Mailing lists > Public > public-script-coord@w3.org > July to September 2015

[Bug 29004] FrozenArray only provides shallow immutability

From: <nobody@w3.org>
Date: Fri, 31 Jul 2015 18:26:52 +0000
To: public-script-coord@w3.org
Message-ID: <bug-29004-3890-AbB9ukSdyn@http.www.w3.org/Bugs/Public/>

--- 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

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:24 UTC