Skip to content

Commit

Permalink
Addressed some of the issues brought up by @jdalton in https://gist.g…
Browse files Browse the repository at this point in the history
  • Loading branch information
kriskowal committed Aug 9, 2011
1 parent 7f09eec commit 21c880d
Showing 1 changed file with 161 additions and 96 deletions.
Loading

9 comments on commit 21c880d

@tkissing
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a specific reason (aside from saving bytes) that you are using 1/0 instead of Infinity or Number.POSITIVE_INFINITY ?

@michaelficarra
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tkissing: 1/0 always produces an Infinity value. Similar to undefined and NaN, Infinity is a writeable (in most cases) global variable that initially contains an Infinity value.

@paulmillr
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say not 'in the most cases', but only in old IEs.

http://es5.github.com/x15.1.html#x15.1.1.2

@michaelficarra
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@paulmillr: I don't know of an interpreter that disallows writing to Infinity outside strict mode. They all implement ES3 15.1.1.2.

The initial value of Infinity is +∞ (section 8.5). This property has the attributes { DontEnum, DontDelete }.

@tkissing
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kitcambridge Which environment allows overriding of Number.POSITIVE_INFINITY? Infinity is a property of the global object, so I understand the objection for that. But Number.POSITIVE_INFINITY should be a true constant.

@michaelficarra
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tkissing: While you're right about the POSITIVE_INFINITY property, that's only useful if we can guarantee we have a reference to the original Number constructor, which is writeable...

@tkissing
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doh. Thanks for the explanations everyone. Guess I will have to live with the warnings during build then (or just see if I can live without any of the shims that use toInteger and remove that code).

@paulmillr
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michaelficarra just checked latest Spidermonkey, Nitro, Carakan & v8 in stable browsers -- no strict mode needed, Inf & undefined can't be redefined.

@michaelficarra
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@paulmillr:

A fairly recent version of node (v8):

$ node --version
v0.6.7
$ node
> Infinity = 4
4
> Infinity
4

And I installed latest stable node just in case:

$ node --version
v0.6.12
$ node
> Infinity = 4
4
> Infinity
4 

And last time I checked v8 through chrome that behaviour existed, but you're right: it has now changed for me as well (using the latest Chrome beta build).

Please sign in to comment.