Hello Jarrett,

On Sun, Feb 22, 2009 at 12:51 PM, Bill Baxter <[email protected]>
wrote:

I use this feature pretty frequently to break up long strings. I
think I didn't use ~ for that because it makes me think an allocation
might happen when it doesn't need to.

But after seeing the discussion here I'd be happy to switch to using
"a"~"b" as long as it's guaranteed by the language that such strings
will be concatenated at compile time.   (I think the is the case now,
right?)

Of course, it does it as a matter of constant folding, just like 3 +
4.


IIRC DMD doesn't always do the constant folding (Decent has a post processed view that shows this in some cases) For instance, IIRC it only does left most so this:

char[] foo = "foo";
char[] bar = foo ~ "bar" ~ "baz"

doesn't get folded. And even if DMD were to start doing that one, there is no requirement that another compiler also do it.


Reply via email to