String reboot
John Rose
john.r.rose at oracle.com
Sun Feb 10 21:05:16 UTC 2019
On Feb 10, 2019, at 8:30 AM, James Laskey <james.laskey at oracle.com> wrote:
>
> I should know better than format e-mails. Many a backslash eaten. The summary should be;
>
>>> For instance; if we got up from the table with the ", """, \", \""" set of delimiters, we could still introduce structured delimiters in the future; either with repeated \ (see Swift) or repeated ". We could also follow a suggestion John made to use a pseudo nonce like \5" for \\\\\" or \""""".
Heh, I wondered about that.
I'd like to propose a term, *for the dessert menu*, to better
capture this idea of a "pseudo-nonce". I call it a "strong
quote". A "strong quote" is a quote drawn from an
infinite non-periodic set of candidates, all of which are
reserved as options for introducing a quoted string.
(Minor point #1: Really I should have said "scheme for
strong quoting and unquoting". But "strong quote"
sounds better and is unambiguous in context.)
(Minor point #2: Strong quotes need strong unquotes.
The set of unquotes needs to be correspondingly infinite,
and each strong unquote needs to be derived from a
corresponding quote. Unquotes could be the same
strings as quotes, reversed strings, etc. They should
to be distinct from something that might occur in
naturally in a string body, like an escape sequence.
The infinite choice of quotes is the major point.)
Two important things to notice about strong quotes:
1. The infinite set is what makes the quotes strong.
Any finite set can be embarrassed by asking it to
quote a string which contains *all* the corresponding
unquotes in the finite repertoire. Any finite choice
takes us into those arguments that say, "surely we
don't care about users who care to quote *that*".
2. The infinite set doesn't need to allow users to
exercise some tasteless creativity, by picking nonces
which (say) encode misleading intentions or irritating
sentiments. The infinite set can be quite simple and
regular.
Two more less important things to notice:
3. The infinite set should not be just the cyclic repetition
of some seed string, like a single quote character. This
is why the word "non-periodic" appears above In the
periodic case (alone) there are some strings which just barely
miss being quotable, because you can't tell when the strong
open quote ends and the string body begins. So the scheme
of repeating a quote character "enough times" just barely
misses being a proper strong quote scheme.
4. User creativity can be excluded even more by positing
a normal form for a strongly-quoted string. In other words,
although there is an infinite choice of strong quotes, the
choice for a specific quote can be made mandatory, based
on the context of the string to be quoted. An obvious
choice is the shortest (or first) strong quote from the
infinite set whose corresponding strong unquote does
*not* occur in the string to be quoted. Whether a
mis-quoted string is reported by an error or a warning
is a further choice in user experience.
The example scheme Jim noted of '\' Numeral '"' is an
example of a strong quoting scheme, with the
corresponding unquotes left as an exercise, including
the task of avoiding collision with existing string body
syntaxes.
HTH
— John
More information about the amber-spec-experts
mailing list