This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 22509 - Some way to express array as readonly and fixed length
Summary: Some way to express array as readonly and fixed length
Status: RESOLVED WONTFIX
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: WebIDL (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Cameron McCormack
QA Contact: public-webapps-bugzilla
URL:
Whiteboard: [v1]
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-28 18:17 UTC by Marcos Caceres
Modified: 2016-10-21 21:15 UTC (History)
6 users (show)

See Also:


Attachments

Description Marcos Caceres 2013-06-28 18:17:03 UTC
Would be nice if the spec provided some way in IDL to express that an array is readonly and/or fixed length. 

http://dev.w3.org/2006/webapi/WebIDL/#idl-array

[[
Arrays can also be designated as being read only.
]]
Comment 1 Rick Waldron 2013-06-28 20:54:35 UTC
Is frozen-ness insufficient?
Comment 2 David Bruant 2013-06-28 21:39:41 UTC
(In reply to comment #0)
> Would be nice if the spec provided some way in IDL to express that an array
> is readonly and/or fixed length. 
Are there cases of fixed length in the platform?

(In reply to comment #1)
> Is frozen-ness insufficient?
I don't think there is a WebIDL way to express that an object is frozen yet (though I agree that could be a solution here)
Comment 3 Boris Zbarsky 2013-06-29 02:08:42 UTC
frozen-ness is not the right thing.

The point of readonly or fixed-length arrays is to return an arraylike object to a caller with the following properties:

1)  The caller can read things from the arraylike.
2)  The caller cannot write things to the arraylike.
3)  The _callee_ can write things to the arraylike as needed.

Most cases where you'd not want the callee to later modify the object just want pass-by-value semantics and actual JS arrays.
Comment 4 Rick Waldron 2013-06-29 02:39:46 UTC
(In reply to comment #3)
> frozen-ness is not the right thing.
> 
> The point of readonly or fixed-length arrays is to return an arraylike
> object to a caller with the following properties:
> 
> 1)  The caller can read things from the arraylike.
> 2)  The caller cannot write things to the arraylike.
> 3)  The _callee_ can write things to the arraylike as needed.
> 
> Most cases where you'd not want the callee to later modify the object just
> want pass-by-value semantics and actual JS arrays.

Got it, thanks for the clarification
Comment 5 Domenic Denicola 2016-10-21 21:15:34 UTC
We used to have this, in T[]. It was removed in favor of FrozenArray and a general movement toward a different pattern of returning a new frozen array object each time. I think we won't go back to a T[]-like world, unless ES somehow add readonly-but-not-immutable arrays as a first-class concept.