Even [[...]]?
Hmm, no. That could be tricky to tell from a type cast at the beginning of an indexing operand.
Another string syntax shouldn't be impossible, or can't it handle dual character string beginnings?
You can say that e.g. both " and ' start string literals. What you can't do is to have different quoting rules inside them; if you say that \ is a quoting character it will do that in both.
Any syntax that has the properties you want will get tricky to support. There has to be a scanner that applies the correct rules and marks up the strings with syntactic text properties to override the defaults. The real problem is to deal with invalidation of those text properties quickly and accurately when the buffer changes.
The multiline is of course even trickier; how is that handled in for instance sh- or perl-mode?
Some quick testing shows that they don't, i.e. they get seriously confused if there's an unbalanced " in such a string literal.
And many newbies to Pike are used to other scripting languages, where you can do multiline strings with a custom delimiter. I think more then one user has actually searched for it in Pike.
I didn't think that was such a common feature. Perhaps a small survey is in order. What are the exact rules for this in other scripting languages then? Say Perl, Python, Tcl, VB, and Ruby?
Afaik none of the syntactically close languages C, C++, Objective-C and Java has anything better. C# has an alternative syntax which is introduced with @ in front of the string: They are called verbatim strings and \ doesn't have any special meaning in them. Any character except " is allowed. They can span multiple lines. " is quoted with "". E.g:
string s = @"Write: ""Hello"" to the C:\ drive.";
I have a vague memory of a pike program that did some complex scripting via a shell; the top number of backslashes in a row was 16 in those strings, that is "\\\\\\\\".
Yes, there are a few insane examples. However a different string syntax would only bring it down to 8 slashes in a row, which is still fairly insane.
/ Martin Stjernholm, Roxen IS
Previous text:
2003-09-21 18:53: Subject: Re: wish: string with other quoting then \
Almost any syntax is only a small matter of programming to implement in the preprocessor.
Even [[...]]?
What concerns me is more all the other tools that has to understand it too, as I talked about in the last discussion about this.
Yes, so it's important that the syntax is as simple as possible.
It's far from easy to get into Emacs and XEmacs, for example.
Another string syntax shouldn't be impossible, or can't it handle dual character string beginnings? The multiline is of course even trickier; how is that handled in for instance sh- or perl-mode?
...
complexity of another string syntax is a drawback in itself when it
...
I'd say that at least 5% of all string literals would have to benefit
I believe that the benefits outweights the cost to the learning curve. It might even help it, if the programs you see use a lot of the characters in strings that would otherwise needed to be quoted. And many newbies to Pike are used to other scripting languages, where you can do multiline strings with a custom delimiter. I think more then one user has actually searched for it in Pike.
I have a vague memory of a pike program that did some complex scripting via a shell; the top number of backslashes in a row was 16 in those strings, that is "\\\\\\\\".
I might be biased, I write a lot of scripts that generate HTML code, or even Pike code. I'd say in bytecount 50% would be quoted using either of these methods. The actual *string* count would of course be much lower.
Given funnier regexps I will probably start using more regexps in my programs too, so the count will increase...
/ Mirar