sweet-core icon indicating copy to clipboard operation
sweet-core copied to clipboard

Fix Ex 5 in the tutorial to match its expansion

Open felipethome opened this issue 8 years ago • 3 comments

The expansion of the example 5 in the tutorial, with sweet.js version 2.0.0, gives for me:

(function (bb8_5) {
  ;
  console.log(bb8_5.beep());
}(new Droid("BB-8", "orange")));

So I added one more ctx.next() and rebuild the docs. Maybe would be better also a check to see if the ; exists?

felipethome avatar Aug 01 '16 17:08 felipethome

Right, you would need to check to make sure the ; exists for the example to really work but that just makes the example more confusing than necessary. Better to have a harmless empty statement in the expansion output imo.

disnet avatar Aug 03 '16 16:08 disnet

But don't you think it is nice for the user to see ; needs to be eaten too? Also, all the examples have their corresponding expansion, but in this particular case the expansion is misleading because it doesn't contain the ;. If you disagree feel free to close it @disnet, and thanks for the attention.

felipethome avatar Aug 03 '16 19:08 felipethome

Actually, why don't you remove the ; from the source? That demonstrates that expansion is ASI aware but avoids complicating the macro code.

disnet avatar Aug 04 '16 17:08 disnet