Multiline string literal improvements
Igor
stojkovic.igor at gmail.com
Wed Oct 11 09:56:52 UTC 2017
On Wednesday, 11 October 2017 at 08:35:51 UTC, Walter Bright
wrote:
> On 10/10/2017 3:16 PM, sarn wrote:
>> Works even better in D because it can run at compile time.
>
> Yes, I see no need for a language feature what can be easily
> and far more flexibly done with a regular function - especially
> since what |q{ and -q{ do gives no clue from the syntax.
You are right. My mind is just still not used to the power of D
templates so I didn't think of this. On the other hand that is
why D is still making me say "WOW!" on a regular basis :).
Just to confirm I understand, for example the following would
give me compile time stripping of white space:
template stripws(string l) {
enum stripws = l.replaceAll(regex("\s+", "g"), " ");
}
string variable = stripws(q{
whatever and ever;
});
And I would get variable to be equal to " whatever and ever; ".
Right?
More information about the Digitalmars-d
mailing list