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 12287 - Restrict sequence<T> to operation argument types and return types
Summary: Restrict sequence<T> to operation argument types and return types
Status: RESOLVED FIXED
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:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-11 01:53 UTC by Cameron McCormack
Modified: 2011-05-23 21:41 UTC (History)
4 users (show)

See Also:


Attachments

Description Cameron McCormack 2011-03-11 01:53:04 UTC
sequence<T> has undesirable behaviour in JS when used as an attribute value, so we should consider preventing its use there.
Comment 1 Ian 'Hixie' Hickson 2011-03-11 20:31:48 UTC
Would be good to have a recommended alternative to (e.g. a note saying to have a method return that type instead).
Comment 3 Olli Pettay 2011-05-23 09:32:08 UTC
(In reply to comment #0)
> sequence<T> has undesirable behaviour in JS when used as an attribute value, so
> we should consider preventing its use there.

Just curious, what that undesirable behavior is? Is it that
JS can modify the array while native code is using it?
Comment 4 Cameron McCormack 2011-05-23 21:41:30 UTC
The undesirable behaviour is that a new Array object would be created every time you access the property.  Simple looping over a sequence attribute, like

  interface Blah {
    readonly attribute sequence<long> numbers;
  };

  for (var i = 0; i < myBlah.numbers.length; i++) {
    doSomethingWith(myBlah.numbers[i]);
  }

would end up doing a lot of wasted work.