AssemblyScript / assemblyscript

A TypeScript-like language for WebAssembly.
https://www.assemblyscript.org
Apache License 2.0
16.72k stars 653 forks source link

Support template literals #466

Open vgrichina opened 5 years ago

vgrichina commented 5 years ago

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

Regular template literals would be very nice for stuff like logging, so that you can basically have stuff like:

log(`transaction: ${hash} status: ${status}`);

instead of current

log('transaction: ' + hash.toString() + ' status: ' + status.toString());

This looks like a feature which only requires compiler-level sugar and zero runtime support.

More than that, we probably can hijack tagged templated literals to support UTF-8 string literals, i.e. have stuff like:

let utf8String = u`Hello, World`;
mdaj06 commented 3 years ago

@dcodeIO can i have a look at it?

vgrichina commented 3 years ago

@mdaj06 BTW this issue is something we are interested to give grant for: https://gov.near.org/t/assemblyscript-grant-q1-2021/697/3

mdaj06 commented 3 years ago

sure got it!

MaxGraey commented 3 years ago

Template literals mostly finished: https://github.com/AssemblyScript/assemblyscript/pull/1715

dcodeIO commented 3 years ago

Initial support for template literals has been merged now, with tagged template literals not enabled just yet due to having to account for an edge case first, which requires implementing ReadonlyArray.