Delimited strings

H. S. Teoh hsteoh at quickfur.ath.cx
Tue Feb 14 17:03:59 PST 2012


On Wed, Feb 15, 2012 at 01:46:51AM +0100, Timon Gehr wrote:
[...]
> No, q"abca" is illegal. The pattern is
> 
> q"identifier
> string
> identifier"
> 
> (The terminating new line is kept, so the string in this case is
> "string\n")

I see. The online specs need to be clarified, then.


[...]
> >So does this mean that you can write:
> >
> >	q"(foo(q"(xxx)"))"
> >
> >and have it represent the string
> >
> >	foo(q"(xxx)")
> >
> >?
> 
> Yes.

I see.


[...]
> >	q"(a)b)"
[...]
> It is illegal because the parens do not match.

OK, I see. Thanks for the clarification.

Makes me wonder, though: what's the purpose of this convoluted
construction? I mean, I can understand why being able to write
q"(z=q"(y)";)" would be useful, but why should it matter that the
parentheses in q"(a(b))" match? What's the purpose of this restriction?


T

-- 
Change is inevitable, except from a vending machine.


More information about the Digitalmars-d-learn mailing list