Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support primitive type "int" #37

Closed
chirayuk opened this issue Sep 30, 2014 · 15 comments
Closed

Support primitive type "int" #37

chirayuk opened this issue Sep 30, 2014 · 15 comments

Comments

@chirayuk
Copy link
Contributor

"int" in ES6 code should translate to "int" in Dart code. For ES5 code, this could be number.

@caitp
Copy link
Contributor

caitp commented Sep 30, 2014

es5 assignment ~= expression | 0 to force smi mode?

@vicb
Copy link
Contributor

vicb commented Sep 30, 2014

"int" is not an ES6 type, right ?

@caitp
Copy link
Contributor

caitp commented Sep 30, 2014

not in the language itself, but it can sometimes be useful to force the VM to treat a value as an integer

@vicb
Copy link
Contributor

vicb commented Sep 30, 2014

What I meant is that "int" is not currently supported by traceur. Does the original issue imply adding "int" support to traceur also ?

@caitp
Copy link
Contributor

caitp commented Sep 30, 2014

What exactly would traceur do to "support int"? it doesn't really exist as a concept/type in es6. You have these: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ecmascript-data-types-and-values

But under the hood of the VM it's a bit more complicated, so we may see advantages (sort of a microoptimization) if we say that declaring a type as an int will ensure that all assignments to it convert it to an SMI representation

@caitp
Copy link
Contributor

caitp commented Sep 30, 2014

it's hard to say whether this would hurt more than it would help or not, but it could be interesting if we want to have typenames

@vicb
Copy link
Contributor

vicb commented Sep 30, 2014

Section 6.1 right below your link:

The ECMAScript language types are Undefined, Null, Boolean, String, Symbol, Number, and Object

I think that Traceur could complain when the "assertTypes" option is enabled "x:int" would be interpreted as x is an instance of the class int.

@caitp
Copy link
Contributor

caitp commented Sep 30, 2014

I mean there's no class, and implementing a class would probably be problematic/not that helpful. Asserting that a type is an int in traceur would probably look more like assert(typeof x === 'number' && (x % 1) === 0) --- which is certainly doable (node null % 1 does === 0, which isn't great). But ultimately I'm just not sure this assertion is super helpful in JS-land

@mhevery
Copy link
Contributor

mhevery commented Sep 30, 2014

We should support int as number. We can assert that it is int by typeof x == number && x === Math.round(x) We very much need this.

@vicb
Copy link
Contributor

vicb commented Oct 7, 2014

fixed

@vicb vicb closed this as completed Oct 7, 2014
@tbosch
Copy link
Contributor

tbosch commented Oct 7, 2014

@vicb With which commit?

@vicb
Copy link
Contributor

vicb commented Oct 8, 2014

Apparently this was fixed in 3482fb1 (PR #49)

@tbosch tbosch reopened this Oct 8, 2014
@tbosch
Copy link
Contributor

tbosch commented Oct 8, 2014

The current solution is only a workaround and should be moved into rtts-assert. Also, the transpiler should be changed to automatically refer to assert.int so we don't need the import for int.

@naomiblack naomiblack added this to the October milestone Oct 14, 2014
@vojtajina
Copy link
Contributor

Yes, we should put this into rtts_assert or Traceur runtime. I will take care of it.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants