<?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>21640</bug_id>
          
          <creation_ts>2013-04-09 12:58:19 +0000</creation_ts>
          <short_desc>Dictionaries and callbacks should be distinguishable</short_desc>
          <delta_ts>2014-09-10 13:29:22 +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>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard>[v1]</status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Robin Berjon">robin</reporter>
          <assigned_to name="Cameron McCormack">cam</assigned_to>
          <cc>annevk</cc>
    
    <cc>bzbarsky</cc>
    
    <cc>jackalmage</cc>
    
    <cc>jib</cc>
    
    <cc>mark_lanthaler</cc>
    
    <cc>mike</cc>
    
    <cc>public-script-coord</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>85785</commentid>
    <comment_count>0</comment_count>
    <who name="Robin Berjon">robin</who>
    <bug_when>2013-04-09 12:58:19 +0000</bug_when>
    <thetext>It seems strange that WebIDL prevents distinguishing between those two when it&apos;s fairly common in code out there to do just that simply by checking that typeof == function.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>86024</commentid>
    <comment_count>1</comment_count>
    <who name="Markus Lanthaler">mark_lanthaler</who>
    <bug_when>2013-04-12 09:57:46 +0000</bug_when>
    <thetext>Just a quick heads up: Assuming that this is indeed a bug, we used method overloading to define the JsonLdProcessor interface in the JSON-LD specification which just went into Last Call (http://www.w3.org/TR/2013/WD-json-ld-api-20130411/#the-jsonldprocessor-interface).

There would be no other way to make the &quot;options&quot; parameter optional and have the callback as last parameter:

  void compact (JsonLdInput input, JsonLdContext context, JsonLdOptions options, JsonLdCallback callback);

JsonLdOptions is a dictionary</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>86028</commentid>
    <comment_count>2</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2013-04-12 10:17:47 +0000</bug_when>
    <thetext>JSON-LD should be using futures there, not callbacks.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>86030</commentid>
    <comment_count>3</comment_count>
    <who name="Markus Lanthaler">mark_lanthaler</who>
    <bug_when>2013-04-12 10:33:43 +0000</bug_when>
    <thetext>We discussed that as well but unfortunately introducing a normative dependency to the DOM spec was not acceptable at this stage.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>86031</commentid>
    <comment_count>4</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2013-04-12 10:40:51 +0000</bug_when>
    <thetext>I would consider creating broken APIs to be less acceptable than any other consideration really.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>86032</commentid>
    <comment_count>5</comment_count>
    <who name="Markus Lanthaler">mark_lanthaler</who>
    <bug_when>2013-04-12 11:30:45 +0000</bug_when>
    <thetext>&quot;Broken&quot; is a quite strong word for a pattern that is well established (and has been so for years)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>86036</commentid>
    <comment_count>6</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-04-12 13:47:11 +0000</bug_when>
    <thetext>Markus, the normal pattern for an API that takes an options property bag is to put it last in the call signature.  Is there a reason that&apos;s not being done here?  (It would indidentally solve your overloading problem, but that&apos;s not why I&apos;m suggesting it, fwiw.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>86038</commentid>
    <comment_count>7</comment_count>
    <who name="Markus Lanthaler">mark_lanthaler</who>
    <bug_when>2013-04-12 14:01:21 +0000</bug_when>
    <thetext>The reason is that we are using node-style callbacks and in node the prevalent pattern is to have the callback last. So it&apos;s basically a matter of &quot;consistency&quot;. Switching the order of the two parameters as you suggest is the backup plan in case the WebIDL bug doesn&apos;t get fixed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>86039</commentid>
    <comment_count>8</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-04-12 14:08:07 +0000</bug_when>
    <thetext>It sounds like in this instance &quot;Node&quot; style and &quot;Web&quot; style don&apos;t agree...  It&apos;s not clear to me why we&apos;re using the former for a web spec (or using webidl for a non-web spec, if this is not a web spec), honestly.

In particular, all sorts of things about dictionaries are optimized for use in web specs....

(As a note, though, the (object or object[]) pattern that spec uses is also not valid WebIDL.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>86040</commentid>
    <comment_count>9</comment_count>
    <who name="Markus Lanthaler">mark_lanthaler</who>
    <bug_when>2013-04-12 14:40:49 +0000</bug_when>
    <thetext>&gt; It sounds like in this instance &quot;Node&quot; style and &quot;Web&quot; style
&gt; don&apos;t agree...  It&apos;s not clear to me why we&apos;re using the former
&gt; for a web spec (or using webidl for a non-web spec, if this
&gt; is not a web spec), honestly.

Hmm... would you mind sending this comment directly to public-rdf-comments@w3.org so that it can be formally addressed? Thanks.

Why is object or object[] not valid WebIDL? The only restriction on arrays I&apos;ve found in the WebIDL spec is the following: &quot;The element type of an array MUST NOT be a sequence or dictionary type.&quot; Is it because object and object[] are not distinguishable? What could we do about that?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>86041</commentid>
    <comment_count>10</comment_count>
    <who name="Tab Atkins Jr.">jackalmage</who>
    <bug_when>2013-04-12 15:11:21 +0000</bug_when>
    <thetext>(In reply to comment #9)
&gt; &gt; It sounds like in this instance &quot;Node&quot; style and &quot;Web&quot; style
&gt; &gt; don&apos;t agree...  It&apos;s not clear to me why we&apos;re using the former
&gt; &gt; for a web spec (or using webidl for a non-web spec, if this
&gt; &gt; is not a web spec), honestly.
&gt; 
&gt; Hmm... would you mind sending this comment directly to
&gt; public-rdf-comments@w3.org so that it can be formally addressed? Thanks.
&gt; 
&gt; Why is object or object[] not valid WebIDL? The only restriction on arrays
&gt; I&apos;ve found in the WebIDL spec is the following: &quot;The element type of an
&gt; array MUST NOT be a sequence or dictionary type.&quot; Is it because object and
&gt; object[] are not distinguishable? What could we do about that?

You can&apos;t do anything about it.  That&apos;s the whole point of &quot;not distinguishable&quot; - you can&apos;t distinguish them in a reliable way.  (Node and other JS libraries often use some arbitrary form of duck-typing to accomplish this, but that doesn&apos;t work at large.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>86042</commentid>
    <comment_count>11</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-04-12 15:22:23 +0000</bug_when>
    <thetext>I sent http://lists.w3.org/Archives/Public/public-rdf-comments/2013Apr/0022.html, fwiw.

For this particular bug, I do think it would be OK to distinguish between dictionaries and callbacks based on [[Call]].  Note that we can&apos;t thus distinguish between dictionaries and callback interfaces.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>86044</commentid>
    <comment_count>12</comment_count>
    <who name="Markus Lanthaler">mark_lanthaler</who>
    <bug_when>2013-04-12 16:30:26 +0000</bug_when>
    <thetext>(In reply to comment #10)
&gt; (In reply to comment #9)
&gt; &gt; Why is object or object[] not valid WebIDL? The only restriction on arrays
&gt; &gt; I&apos;ve found in the WebIDL spec is the following: &quot;The element type of an
&gt; &gt; array MUST NOT be a sequence or dictionary type.&quot; Is it because object and
&gt; &gt; object[] are not distinguishable? What could we do about that?
&gt; 
&gt; You can&apos;t do anything about it.  That&apos;s the whole point of &quot;not
&gt; distinguishable&quot; - you can&apos;t distinguish them in a reliable way.  (Node and
&gt; other JS libraries often use some arbitrary form of duck-typing to
&gt; accomplish this, but that doesn&apos;t work at large.)

Are saying that an implementation of the API wouldn&apos;t be able to find out what has been passed? What about ECMAScript 5&apos;s isArray function?

This methods are used to transform JSON-LD documents which can be objects or arrays as at the top-level (just as JSON according RFC4627). We use the (object or object[]) union type to describe that in WebIDL. What other type should we use instead? Just object since an array is also an object? I fear that would confuse most readers.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>86045</commentid>
    <comment_count>13</comment_count>
    <who name="Markus Lanthaler">mark_lanthaler</who>
    <bug_when>2013-04-12 16:34:08 +0000</bug_when>
    <thetext>(In reply to comment #11)
&gt; I sent
&gt; http://lists.w3.org/Archives/Public/public-rdf-comments/2013Apr/0022.html,
&gt; fwiw.

Thanks.


&gt; For this particular bug, I do think it would be OK to distinguish between
&gt; dictionaries and callbacks based on [[Call]].

Great. I hope others agree.


&gt; Note that we can&apos;t thus distinguish between dictionaries and callback
&gt; interfaces.

OK.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91603</commentid>
    <comment_count>14</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2013-08-04 07:33:47 +0000</bug_when>
    <thetext>The JSON-LD issue was resolved to not require dictionaries and callbacks to be distinguishable, so closing as WONTFIX.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>