6

Reading documentation about fileReader, and find out that they write methods using void operator, like this:

void readAsArrayBuffer (
        in Blob blob
);

just trying understand why they do write it like this? If there is any practical use of this syntax?

Later on it turns out not to be js at all, but IDL which is Interface Description Language.

FYI: before asking this question I do google and read about actual void operator in JS. So please there no needs reffer me back. Question little bit blurry, but it has to deal with, why Mozilla has documentation about JavaScript written like this? In IDL which has little with actual JavaScript?

Mikko Ohtamaa
  • 69,174
  • 40
  • 208
  • 346
dmi3y
  • 3,152
  • 2
  • 19
  • 31
  • 5
    That's not the `void` operator. That's a `void` return value, which means no value is returned. Two different things. – mellamokb Dec 08 '12 at 00:37
  • 1
    Actually `void` returns `undefined` and being used to return nothing most of the times used in `link` like [this](http://jsbin.com/ocihej/1/edit), [could be helpful](http://www.tutorialspoint.com/javascript/javascript_void_keyword.htm). – The Alpha Dec 08 '12 at 00:41
  • [Also look at this answer](http://stackoverflow.com/questions/666936/what-is-the-point-of-void-in-javascript) and [this one too](http://stackoverflow.com/questions/12998620/whats-a-good-use-of-void). – The Alpha Dec 08 '12 at 00:44
  • 4
    W3C DOM API specs are not written as JavaScript. It's a weird IDL syntax that annoys a lot of people. – Pointy Dec 08 '12 at 00:59
  • @Pointy oh well, that's interface description, not js at all. http://mxr.mozilla.org/mozilla-central/source/content/base/public/nsIDOMFileReader.idl Thank you! You actually, can post answer – dmi3y Dec 08 '12 at 06:57
  • @SheikhHeera this question has absolutely nothing to do with the `void` operator in JavaScript. The posted code in the question is not JavaScript. – Pointy Dec 08 '12 at 13:43
  • @SheikhHeera well the question refers to the W3C DOM documentation, which is written with an IDL syntax (not JavaScript, which is a bit strange). It can be confusing sometimes. – Pointy Dec 08 '12 at 14:08
  • 2
    @SheikhHeera [Here is a link to the Web IDL documentation.](http://www.w3.org/TR/WebIDL/) – Pointy Dec 08 '12 at 14:25
  • 1
    The specification is formally designed to be as abstract as possible. It "just happens" (not really of course) that most implementors are just browsers which use JavaScript. Not sure why they didn't leave this abstract stuff out (MDN generally is simplified for browser developers). – pimvdb Dec 11 '12 at 19:31

1 Answers1

4

Mozilla uses IDL for in two ways

  • Web IDL: used in W3C specifications and such to describe Javascript APIs. These are the normative specifications.

  • XPCOM internal IDL dialect: The native Javascript APIs are implemented in C++. In Gecko's (Firefox's engine's) case, specifically in domain specific framework called XPCOM

As the linked page states, Gecko internally describes interfaces in language neutral IDL dialect, because those interface must be implemented both in native run-time (C++) and Javascript engine (Javascript).

In this case the IDL description is either copy-paste from the orignal Web IDL specification or from Gecko's internal implementation.

Bergi
  • 513,640
  • 108
  • 821
  • 1,164
Mikko Ohtamaa
  • 69,174
  • 40
  • 208
  • 346