quasi-literal strawman

Dean Landolt dean at deanlandolt.com
Mon Dec 14 17:06:30 PST 2009


On Mon, Dec 14, 2009 at 7:04 PM, Mike Samuel <mikesamuel at gmail.com> wrote:

> 2009/12/14 Ash Berlin <ash_js at firemirror.com>:
> >
> > On 14 Dec 2009, at 22:44, Mike Samuel wrote:
> >
> >> http://wiki.ecmascript.org/doku.php?id=strawman:quasis
> >> is a strawman for a concrete syntax that enables string interpolation
> >> as described in
> >> http://wiki.ecmascript.org/doku.php?id=strawman:string_interpolation .
> >>
> >> So far it's just an uploaded HTML file but I plan to make it more wiki
> friendly.
> >> If people want to edit it, let me know and I'll put out a wiki form
> pronto.
> >
> > First things first: the string interpolation strawman[1] is not string
> interpolation. It's LINQ (Language Integrated Query) or very similar, which
> dare I say it, is what E4X is (or attempts to be, spec bug not withstanding)
> Which isn't to say I don't think the idea has merit, it is just more than
> simply string interpolation. (When i say its LINQ - it feels very much like
> the query syntax front end for it.)
>
> I'll look into LINQ.  I think it's more general purpose than E4X, but
> I've never read the E4X spec so take that with a grain of salt.
>
>
> > The pessimist in my would like to point out that you could (and people
> inevitably will) still say `UPDATE foo SET x=$x`. Unless i've missed
> something crucial this doesn't protect against that (as its not  a
> sql`UPDATE ...`. Also which 'sql' - there are many variants)
>
> Please see the late binding arguments in
>
> http://google-caja.googlecode.com/svn/changes/mikesamuel/string-interpolation-29-Jan-2008/trunk/src/js/com/google/caja/interp/index.html
> for an explanation of why the sql prefix is unnecessary, and as you
> describe, often damaging.
>
>
> > backticks In perl, ruby and php is all the system execute command (which
> I suspect you know) but the "where it allows interpolation though with a
> more specific meaning than macro expansion" wording isn't quite correct --
> it does more than just interpolattion.
>
> Yes, you're right.  It interpolates first and then executes it as a
> shell command in perl and PHP, and I believe ruby.
>
> > I really like the idea of being able to do things like |var my regexp =
> re`(?i:\w+$foo\w+)`;|
> >
> > quasi-strawman.html says:
> >>> It would be convenient for some DSL use cases to allow LineTerminators
> inside code, but it is unclear how this will interact with revision control
> systems that rewrite newlines on checkout
> >
> >
> > If you want to use a certain form of a new line for what ever reason, it
> would probably be best to use \n. Line continuations are rather annoying to
> use in practice - if you want the literal to be split over multiple lines,
> and to have new lines in the source you end up ending every line with \n\
> which is just ugly. Since we are already talking about new syntax, I would
> vote for allowing multi-line literals.
>
> So to keep score:  (for multi-line 1, against: 0, unspecified, ~6B :)
>


Just to update the scoreboard, I could tick off at least a few dozen people
that I've heard gripe about a lack of multiline literals. So ~6B -
~30...that enough? No? Damn.

But seriously, I do believe that this type of proposal is a huge opportunity
to bring multiline strings to js syntax. It would be a shame it didn't
include some mechanism for it.

[snip]


> > I can understand not having printf style formatting codes, but how would
> you suggest you format a number to 2 decimal places?
>
> `Avg. Rainfall: ${n.ToFixed(2)}cm`
>

Touché. I could live with that.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20091214/e5b8ec2c/attachment.html>


More information about the es-discuss mailing list