tc39 / proposal-binary-ast

Binary AST proposal for ECMAScript
965 stars 23 forks source link

Consider merging LiteralInfinityExpression into LiteralNumericExpression #71

Open RReverser opened 5 years ago

RReverser commented 5 years ago

As discussed on Gitter, we might want to do this to simplify handling and provide optimised representations (like https://github.com/binast/binjs-ref/issues/239) more easily for both kinds of numbers.

Some points from the discussion:

cc @syg @Yoric @arai-a

michaelficarra commented 5 years ago

As far as codegen, 2e308 is the common "canonical" representation of Infinity for doubles. So that's not really a problem. But you should consider whether most usage will care to differentiate between finite and infinite numbers.

Another consideration you may have is JSON representation, which is the original motivator for the Shift AST to have these two nodes separated.

RReverser commented 5 years ago

But you should consider whether most usage will care to differentiate between finite and infinite numbers.

Aside from stringification, currently other cases (like the one mentioned above) seem to actually benefit from having these represented in the same way.

Another consideration you may have is JSON representation

But this is a good point. While (I believe) JSON is a second-class citizen for BinaryAST and is mostly intended for debugging purposes, this would have to be solved somehow if the change is adopted.

Yoric commented 5 years ago

While (I believe) JSON is a second-class citizen for BinaryAST and is mostly intended for debugging purposes, this would have to be solved somehow if the change is adopted.

At the moment, that's true, because we used a strongly-typed internal representation, but that's no written in stone.