Alternate string literal syntax (with mixins)?
Kristian Kilpi
kjkilpi at gmail.com
Sun Feb 11 07:59:51 PST 2007
Argh, I hit the 'reply' button instead of 'new mail' button, so this mail
was send to this thread. I'm posting this to the root thread also...
Sorry. (So please don't reply to this one.)
On Sun, 11 Feb 2007 17:52:20 +0200, Kristian Kilpi <kjkilpi at gmail.com>
wrote:
>
> String literals with mixins are a bit awkward sometimes (editor
> highlighting etc).
>
> Some special marks -- I use @{ }@ here -- could be used to mark a part
> of a source file as a string literal, just like /* */ marks a part of
> code as a comment. For example:
>
> mixin(
> @{
> //this is a string literal block
> if(...) {
> ...
> }
> }@
> );
>
> The @{ }@ marks have a close relation, of course, with quotation marks
> "". But because there is a starting mark and an ending mark, you can
> nest them. (And because they are used to mark a part of a file as a
> string literal, they are not actually the part of the 'working code'
> just like the "" literals are, if you get what I'm trying to say.)
>
> E.g.
>
> alias @{
> str = @{ foo }@ ~ @{ bar }@;
> str ~= "blah";
> if(...) {
> ...
> }
> }@ MyCode;
>
> mixin(MyCode);
More information about the Digitalmars-d
mailing list