extensibleweb / webidl.js

An implementation of WebIDL in ECMAScript
55 stars 14 forks source link

implement long long type #10

Open marcoscaceres opened 11 years ago

marcoscaceres commented 11 years ago

http://www.w3.org/TR/WebIDL/#idl-long-long

marcoscaceres commented 11 years ago

Implemented LongLong as it's in the spec, but it won't work because the numbers are too big for JS. We need a way to covert them.

@FremyCompany, you are our resident Math guy!:) Can you help?

For reference, Google did it like this: http://closure-library.googlecode.com/svn/docs/closure_goog_math_long.js.source.html

FremyCompany commented 11 years ago

I'm afraid we're going to use boxing here, like Google did, since you cannot do better.

However, since JavaScript can't send 'long long' values and that you cannot return 'long long' values to JavaScript (you'll be restricted by what a Number can hold), this does not really matter: the LongLong type can only be used inside an API.

We can include support for long long as something optional that uses boxing and rely on Google's implementation (ie: if you want to make a polyfill using long long, then you need to include the Google API for it to work, or you accept to loose precision during the calculations).

What do you think of that?

marcoscaceres commented 11 years ago

I think that that is fine. Like you said, there is no use case for long long in JS itself - only for something that would be running boxed (or in C++).

So we should just de-prioritize supporting this altogether for now and maybe just throw an NotSupportedError.