lydell / frappe

JavaScript with some nice fluff on top of it.
7 stars 1 forks source link

Ambiguous syntax between tagged template literals and parentheses-less function calls #5

Closed forivall closed 8 years ago

forivall commented 8 years ago

the following code

a "a"

could be interpreted as a function call or a tagged template string, since, in javascript, a space can occur between the tag and the template string.

In tacoscript (in which I have implemented parts of, and will be implementing other parts of frappe), only `` will be used for template tags, and I've completely changed the meaning of!`, where it can be used for any parentheses-less function calls, so it will be required if the first and only argument is a template literal.

The other possible solution would be to require no space between the template tag and the template string: template string: a"a" vs function call: a "a"

Semantically, these are the same thing, so, possibly, it just wouldn't matter?

lydell commented 8 years ago

the following code

a "a"

could be interpreted as a function call or a tagged template string, since, in javascript, a space can occur between the tag and the template string.

But not in frappe. There, no space is required. This is probably not clear from the README though, since I had no idea that you could put a space there in JavaScript.

forivall commented 8 years ago

Duh, I just thought of an even simpler example

a [i]

is an array / object index / property getter in javascript, but I assume that, likewise, a space there would turn it into a function call.

lydell commented 8 years ago

Correct. Guess there's no need to mention it then.