quasi-literal strawman

Mike Samuel mikesamuel at gmail.com
Thu Dec 17 20:15:10 PST 2009


2009/12/17 Kris Kowal <kris.kowal at cixar.com>:
> I am also in favor of the quasi-literal type name not being mangled.
> I would, in fact, consider making the quasi-literal type any
> expression returning a function, even if this necessitates a
> parenthetical expression.

Cool.

> You might consider refining the escaping rules to resemble r"raw
> strings" as in Python.  That would afford a greater degree of
> flexibility in escaping rules within the quasi-literal.  The only
> difference is that in a raw string, only backslash before the same
> quote character as the enclosing quotes and a backslash are treated as
> escape characters and all others are preserved.  Then, the
> quasi-literal function would be entirely in control of the meaning of
> other escaped characters.

That's the case right now, except that to escape a backtick one does
$\`  instead of \`.


> There's also a trade-off between using back-ticks and plain
> double-quotes.  Using back-ticks affords us an opportunity to have a
> "default" quasi-literal.  On the other hand, I don't miss having to
> distinguish front and back ticks in Perl.  Also, it might be
> undesirable to have to claim a variable name for the default case,
> unless your intention is that the default quasi-literal have a
> consistent behavior in any scope.

So is this a vote for a mandatory type tag followed by normal quote
syntax (the second alternative under "Quoting Characters"), so
   foo"bar"   is a quasi string

   "bar"        is not a quasi string

   foo\
   "bar"        is a quasi string

   foo
   "bar"        is not a quasi string


If there is a default quasi function, do you have any preference re its name?



> In one of my former language projects, I considered something similar
> for numbers, in suffix.  For example: 3ce for "thrice" or 1mm for "one
> millimeter", where "ce" and "mm" were constructors in scope.

I think C++0x has something along those lines:
http://en.wikipedia.org/wiki/C%2B%2B0x#User-defined_literals


> Kris Kowal
>


More information about the es-discuss mailing list