Multiline string literals
Bruce Chapman
brucechapman at paradise.net.nz
Mon Aug 8 03:04:02 PDT 2011
On 8/08/2011 8:16 p.m., Maurizio Cimadamore wrote:
> On 07/08/11 14:54, Artur Biesiadowski wrote:
>> Because it is not only about multiline literals, it is about avoiding
>> escaping common expressions - in particular, "" delimited strings.
>>
>> This is why somebody was discussing 'single line multiline string
>> literal' here ;)
> Hi,
> it seems to me that we are asking for a silver bullet that solves all
> our string-related problems; how much would we need escaping for
> delimited strings if we had explicit syntax support for XML, JSON (etc.)
> literals (possibly checked at compile-time against a schema?)
Well, Java is a general purpose programming language, so general
language features are (highly) favoured over application specific
language features. Following that means it is better to have one string
syntax that supports multiline strings (irrespective of whether or not
that is the same as the existing syntax), tham to have separate syntax
for XML, JSON, my_favourite_syntax or your_favourite_syntax. This
applies at least until the general purpose syntax creates a high level
of pain for a very common application - at which point a better syntax
can be investigated.
> - at the end of the day, a string is a string - there's nothing much the compiler
> can do about it;
Annotation processors (or some future similar compiler feature) can
(could) parse the general purpose string against an application specific
syntax and syntax specific errors could be generated at compile time.
I've done it for XML.
> on the other hand, most of the examples of multiline
> strings I've seen in this discussion do have a 'structure' that can be
> checked.
>
Yes, so hand in hand with a general purpose multiline string literal, it
would be good to investigate ways of having pluggable syntax checkers
for these. I don't believe this would require any new language feature.
I can provide a strawman if there is interest.
Bruce
> Maurizio
>> Regards,
>> Artur Biesiadowski
>>
>> On 07/08/2011 13:36, Rémi Forax wrote:
>>> An why not using " ?
>>> why do we need a different syntax for single line and multiple lines
>>> string literals ?
>>>
>
More information about the coin-dev
mailing list