Setting up (non-index) properties of arrays
The desugaring in the wiki proposal must not be observable.
Separately, we've long entertained extending array literals to encompas ad-hoc properties (expandos). Also the dict strawman wants [a:1,b:2] syntax. I think expandos on arrays are rare enough that dicts should win, if it comes down to a future-proofing fight.
Brendan Eich wrote:
The desugaring in the wiki proposal must not be observable.
Indeed I don't believe Allen is spec'ing template strings via desugaring at all.
Separately, we've long entertained extending array literals to encompas ad-hoc properties (expandos). Also the dict strawman wants [a:1,b:2] syntax. I think expandos on arrays are rare enough that dicts should win, if it comes down to a future-proofing fight.
Agreed on rareness. If dicts are only maps from string to value [1] (a safe object-as-map, if you will) then I don’t think we need a literal/initializer syntax for that – they can easily be initialized via object literals, e.g.: dict({ a: 1, b: 2 })
However, [a:1,b:2] or {| a: 1, b: 2 |} would be great as a literal syntax for maps (from value to value). That is, a
and b
would be identifiers and not string keys. But that must make parsing difficult. Even something very restrictive (such as: parens if there is more than one token in the expression) does not seem much help.
[1] strawman:dicts
On Aug 4, 2012, at 12:06 AM, Axel Rauschmayer wrote:
... How about the following abbreviation?
const callSiteId1234 = ['lit1\n', ' lit2 ', '', raw: ['lit1\\n', ' lit2 ', '']];
Or, using :=
const callSiteId1234 = ['lit1\n', ' lit2 '] := {raw: ['lit1\n', ' lit2 ', ''};
(ignoring all the other issues about why this isn't a great example)
As an example, a template string call site ID would be constructed as follows:
How about the following abbreviation?
Not sure it’s a frequent-enough use case, though. Mustache would be nice here, or one could use Underscore: