<?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>5814</bug_id>
          
          <creation_ts>2008-06-27 08:34:38 +0000</creation_ts>
          <short_desc>WebIDL: Resolve the callback issue</short_desc>
          <delta_ts>2010-10-04 13:59:46 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>HTML WG</product>
          <component>pre-LC1 HTML5 spec (editor: Ian Hickson)</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>VERIFIED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>NoReply</keywords>
          <priority>P4</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ian &apos;Hixie&apos; Hickson">ian</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>cam</cc>
    
    <cc>mike</cc>
    
    <cc>public-html-admin</cc>
    
    <cc>public-html-wg-issue-tracking</cc>
          
          <qa_contact name="HTML WG Bugzilla archive list">public-html-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>20955</commentid>
    <comment_count>0</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2008-06-27 08:34:38 +0000</bug_when>
    <thetext>Right now callbacks are defined in terms of heavy interfaces first, and then turned into functions for JS. We should make the function form primary, and make the interface get generated from rules in WebIDL for those languages that need it.

We need some sort of syntax in WebIDL to define callbacks, including the signature of the callback.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>21185</commentid>
    <comment_count>1</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2008-07-15 11:11:56 +0000</bug_when>
    <thetext>also make sure TimeoutHandler can be handled by this mechanism</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>22527</commentid>
    <comment_count>2</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2008-11-24 23:58:20 +0000</bug_when>
    <thetext>(In reply to comment #0)
&gt; Right now callbacks are defined in terms of heavy interfaces first, and then
&gt; turned into functions for JS. We should make the function form primary, and
&gt; make the interface get generated from rules in WebIDL for those languages that
&gt; need it.

Why?  Not all languages support freestanding functions, but languages that Web IDL can target are already required to support interfaces in some form.  It makes sense to me to have the interface be the primary means of specifying callbacks.

If there were Web IDL syntax to specify the handler function outside of an interface, there would still need to be something to give the name of the interface (and operation name) for non-ECMAScript language bindings, so you may as well just use the interface syntax.

&gt; We need some sort of syntax in WebIDL to define callbacks, including the
&gt; signature of the callback.

What you can do now is:

  [Callback, NoInterfaceObject]
  interface MyHandler {
    void handleEvent(in DOMString something);
  };

If you specifically want to disallow { handleEvent: function() ... } from being a callback, you can use [Callback=FunctionOnly].  I was considering removing the FunctionOnly (and PropertyOnly) arguments to [Callback] so that callbacks can be implemented in script uniformly, though.

(In reply to comment #1)
&gt; also make sure TimeoutHandler can be handled by this mechanism

  [Callback=FunctionOnly, NoInterfaceObject]
  interface TimeoutHandler {
    void handleEvent([Variadic] in any args);
  };

That would handle the current behaviour of most browsers not treating the object&apos;s handleEvent property as the implementation of the callback.  I think it would be good if implementations did allow this, though, for consistency.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>22528</commentid>
    <comment_count>3</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2008-11-25 00:03:04 +0000</bug_when>
    <thetext>I guess I can live with that, but it still seems heavy-duty to me.

I&apos;d prefer something like:

  callback TimeoutHandler ([Variadic] in any args);

...at the top level, i.e. introducing a new type, followed by just using it as if it was a defined type.

I don&apos;t mind it being turned into an interface for languages that have no function types, but it is first and foremost a callback, not an interface, IMHO.

The { handleEvent: function() ... } thing seems like an accident to me, not something we should encourage.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>22529</commentid>
    <comment_count>4</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2008-11-25 00:23:42 +0000</bug_when>
    <thetext>(In reply to comment #3)
&gt; I guess I can live with that, but it still seems heavy-duty to me.

It&apos;s really only heavy duty in the sense that it takes a few more characters to type.

&gt; I&apos;d prefer something like:
&gt; 
&gt;   callback TimeoutHandler ([Variadic] in any args);
&gt; 
&gt; ...at the top level, i.e. introducing a new type, followed by just using it as
&gt; if it was a defined type.

I&apos;ve been reluctant so far to introduce features that are syntactically incompatible with OMG IDL.

&gt; I don&apos;t mind it being turned into an interface for languages that have no
&gt; function types, but it is first and foremost a callback, not an interface,
&gt; IMHO.

It&apos;s an interface that user code needs to implement to be called back, no? :)

&gt; The { handleEvent: function() ... } thing seems like an accident to me, not
&gt; something we should encourage.

But that is how DataGridProvider is expected to be implemented.  I&apos;d prefer that regardless of the number of operations on a callback interface it be implementable using properties, for consistency.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>22530</commentid>
    <comment_count>5</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2008-11-25 01:10:39 +0000</bug_when>
    <thetext>DataGridProvider isn&apos;t a callback, so... :-)

Anyway, I can live with the current syntax.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>32965</commentid>
    <comment_count>6</comment_count>
    <who name="Maciej Stachowiak">mjs</who>
    <bug_when>2010-03-14 13:14:43 +0000</bug_when>
    <thetext>This bug predates the HTML Working Group Decision Policy.

If you are satisfied with the resolution of this bug, please change the state of this bug to CLOSED. If
you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

This bug is now being moved to VERIFIED. Please respond within two weeks. If this bug is not closed, reopened or escalated within two weeks, it may be marked as NoReply and will no longer be considered a pending comment.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>