WYSIWYG string still limited
Kirk McDonald
kirklin.mcdonald at gmail.com
Sat Dec 15 13:18:01 PST 2007
Swer wrote:
> r"abc\s*$" ok
> r"abc"s*$" fail
>
> `abc"s*$` ok
> `abc`s*$` fail
>
> as a improvement from C/C++, D use [`] as WYSIWYG string delimiter easy to
> use, but still not enough. why dont perfect solution to WYSIWYG string. perl
> has one, but not fit for D. My poposal below.
>
> pargam(delimiter, "[[WYSIWYG]]");
>
> const char [] somestr = [[WYSIWYG]]
> You can use write any some here.
> const char [] code_demo1 = `demo1`;
> const char [] code_demo2 = r"demo2";
> [[WYSIWYG]]
>
> ofcause you can replace the delimiter from "[[WYSIWYG]]" to any string you
> like.
>
>
The D 2.x series has already added a few new forms of string literals,
including delimited strings. They look like this:
q"(foo(xxx))" // "foo(xxx)"
q"[foo{]" // "foo{"
q"/foo"bar/" // "foo\"bar"
They are documented here:
http://digitalmars.com/d/lex.html#StringLiteral
--
Kirk McDonald
http://kirkmcdonald.blogspot.com
Pyd: Connecting D and Python
http://pyd.dsource.org
More information about the Digitalmars-d
mailing list