<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>23623</bug_id>
          
          <creation_ts>2013-10-24 13:52:01 +0000</creation_ts>
          <short_desc>Support [Clamp] for sequences</short_desc>
          <delta_ts>2017-03-30 16:21:36 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>WebIDL</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Michael van Ouwerkerk">mvanouwerkerk</reporter>
          <assigned_to name="Cameron McCormack">cam</assigned_to>
          <cc>annevk</cc>
    
    <cc>bzbarsky</cc>
    
    <cc>chris</cc>
    
    <cc>mike</cc>
    
    <cc>nbarth+w3bugzilla</cc>
    
    <cc>public-script-coord</cc>
    
    <cc>tobie.langel</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>95304</commentid>
    <comment_count>0</comment_count>
    <who name="Michael van Ouwerkerk">mvanouwerkerk</who>
    <bug_when>2013-10-24 13:52:01 +0000</bug_when>
    <thetext>It would be very useful to clamp the contents of a sequence:
[Clamp] sequence&lt;unsigned long&gt;

We ran into the need for this in the Vibration API, where clamping of the contents of a vibration pattern would be more appropriate.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95307</commentid>
    <comment_count>1</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2013-10-24 14:13:17 +0000</bug_when>
    <thetext>If you do not mean sequence&lt;[Clamp] unsigned long&gt;, could you please elaborate on what you are proposing here?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95308</commentid>
    <comment_count>2</comment_count>
    <who name="Michael van Ouwerkerk">mvanouwerkerk</who>
    <bug_when>2013-10-24 14:15:20 +0000</bug_when>
    <thetext>Hi Anne, not sure whether the syntax is the one I posted or the one you posted. But the idea is to clamp the values in the sequence.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95311</commentid>
    <comment_count>3</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2013-10-24 14:24:40 +0000</bug_when>
    <thetext>Right, that should already work with the syntax I posted.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95312</commentid>
    <comment_count>4</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2013-10-24 14:50:56 +0000</bug_when>
    <thetext>The spec doesn&apos;t allow that currently though, right?  [Clamp] goes on things like attributes, operation argument, etc.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95314</commentid>
    <comment_count>5</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2013-10-24 14:53:17 +0000</bug_when>
    <thetext>Oh really? I guess it&apos;s only allowed at a syntax level then. Seems like that always ought to work though. E.g. if we have &quot;[Test] DOMString&quot; it should work regardless of context.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95329</commentid>
    <comment_count>6</comment_count>
    <who name="Nils Barth">nbarth+w3bugzilla</who>
    <bug_when>2013-10-25 01:40:37 +0000</bug_when>
    <thetext>Anne, it&apos;s tempting to attach extended attributes to types, but the grammar (and semantics) are significantly easier if we attach to operation arguments (and members) instead. Syntactically:
[ExtAttr] sequence&lt;long&gt; foo
...instead of:
sequence&lt;[ExtAttr] long&gt; foo

This is b/c extended attributes appear at 3 levels:
* definitions (interfaces etc.),
* members (attributes, operations, etc.),
* arguments (to operations).

Extended attributes basically don&apos;t attach to types; if they did, we&apos;d need to handle nesting, so these would have different meanings:
[ExtAttr] sequence&lt;long&gt; foo
sequence&lt;[ExtAttr] long&gt; foo
...and there would be ambiguity of whether an ExtAttr applies to a type or an argument (or an attribute etc.); this:
[ExtAttr] sequence&lt;long&gt; foo
parses 2 ways:
([ExtAttr] sequence&lt;long&gt;) foo
[ExtAttr] (sequence&lt;long&gt; foo)
...which is pretty ugly.

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

Note that in the Candidate Recommendation, extended attributes are applicable to typedefs:
typedef [Clamp] octet Value;
http://www.w3.org/TR/WebIDL/#dfn-typedef
...so:
sequence&lt;Value&gt;
in principle expands to:
sequence&lt;[Clamp] octet&gt; 
...but this makes quite a mess (as above), and is not present in the Editor&apos;s Draft:
http://dev.w3.org/2006/webapi/WebIDL/#dfn-typedef

Hope this helps!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95335</commentid>
    <comment_count>7</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-10-25 04:34:02 +0000</bug_when>
    <thetext>So this is specifically talking about [Clamp] applied to a sequence&lt;T&gt; where T is a type that [Clamp] can currently be applied to, right?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95336</commentid>
    <comment_count>8</comment_count>
    <who name="Nils Barth">nbarth+w3bugzilla</who>
    <bug_when>2013-10-25 05:56:42 +0000</bug_when>
    <thetext>(In reply to Boris Zbarsky from comment #7)
&gt; So this is specifically talking about [Clamp] applied to a sequence&lt;T&gt; where
&gt; T is a type that [Clamp] can currently be applied to, right?

Yes, exactly: we want |[Clamp] sequence&lt;T&gt;| to mean &quot;clamp all terms of sequence&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95675</commentid>
    <comment_count>9</comment_count>
    <who name="Michael van Ouwerkerk">mvanouwerkerk</who>
    <bug_when>2013-11-01 13:17:18 +0000</bug_when>
    <thetext>This bug is one of the last dependencies for finalizing the Vibration API. Do you have an estimate for when it might be fixed? Is there anything I could help with? I&apos;m not sure how much work it is, or how much time the Web IDL folks have available for looking at this. Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>128516</commentid>
    <comment_count>10</comment_count>
    <who name="Tobie Langel">tobie.langel</who>
    <bug_when>2017-03-30 16:21:36 +0000</bug_when>
    <thetext>Fixed by https://github.com/heycam/webidl/commit/faaaaa9ffb548a303db362a09e4b1504c4605e0c</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>