On Thu, Oct 22, 2015 at 7:20 PM, Caitlin Potter <caitpotte...@gmail.com> wrote:
> Cute, but nobody is realistically going to do that. > Since `${}` is a static error, what do you realistically think people will do? Especially if they meant `${''}`, how do you expect them to react to the static error? > > Possible valid uses for the empty placeholder: > > - Contents of expression commented out, maybe debugging if it causes side > effects which may be harmful > - Expression is a placeholder, with contents soon to come (mentioned by OP) > > The DSL thing is a non-issue, because the empty expression didn't need to > be included in the list of expressions, and if it is included, DSLs can be > smart enough to deal with it, and should probably be implemented as a > recursive descent parser on top of the interpolated text anyways > > Ease of use, ease of debugging, ease of editing. Users of JS don't make > the distinction between a Statement and Expression or ExpressionStatement, > and interpolated strings are very much about strings. > A surprising static error is better than a dynamic error that silently violates programmer expectations. If I saw `${}` and did not know what it means, I would sooner guess undefined than ''. Code that matters is read more often than it is written. By making `${}` a static error, we spare readers the hazard of trying to guess what this rare edge case would do. > > On Oct 22, 2015, at 7:05 PM, Mark S. Miller <erig...@google.com> wrote: > > It is an unnecessary special case. The empty string is a valid statement > (aside from the semicolon) but not a valid expression. The syntax of what > appears between the curlies is expression. > > Having it default to the empty string makes no sense. Why not 0, false, > null, or undefined? Remember that template strings can be used to make > arbitrary objects using any DSL that your tag knows how to parse. There's > nothing about template strings that is about strings in either the > substitution values or the result values. > > If you want the equivalent of `${''}`, just say `${''}`. > > > > On Thu, Oct 22, 2015 at 6:31 PM, Caitlin Potter <caitpotte...@gmail.com> > wrote: > >> >> Doesn't necessarily seem like a bad idea. I could be on board with that. >> >> > On Oct 22, 2015, at 6:18 PM, Mohsen Azimi <m...@azimi.me> wrote: >> > >> > Pardon my lack of use of proper terminology. >> > >> > This is kind of annoying working with large template strings. When I >> leave an interpolation placeholder(what's the right name?) empty it blows >> up all my code. >> > >> > Can it be forgiving like Ruby and CoffeScript and just replace it with >> empty string? >> > _______________________________________________ >> > es-discuss mailing list >> > es-discuss@mozilla.org >> > https://mail.mozilla.org/listinfo/es-discuss >> _______________________________________________ >> es-discuss mailing list >> es-discuss@mozilla.org >> https://mail.mozilla.org/listinfo/es-discuss >> > > > > -- > Cheers, > --MarkM > > > _______________________________________________ > es-discuss mailing list > es-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > > -- Text by me above is hereby placed in the public domain Cheers, --MarkM
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss