On 2010-07-11 08:47:26 -0400, "Lars T. Kyllingstad"
<[email protected]> said:
On Sun, 11 Jul 2010 14:26:51 +0200, Philippe Sigaud wrote:
That's interesting. Do you have a link or any text I could read on that?
String mixins sure are powerful, but I can't get ird of a feeling of
'cheating' when using them. Maybe with some kind of string interpolation
they could be made more palatable to some?
I find that using token strings, q{ ... }, rather than ordinary "..."
strings, sometimes makes string mixins feel less like a hack. Especially
considering that my editor (vim) highlights token strings like ordinary
code -- or, more likely, it doesn't recognise them as strings. ;)
Personally, I find it *more* like a hack. q{...} is just a way to
disguise a string as not being one, it's like using a second hack to
better hide the first hack. But it's too hacks instead of one, and thus
it's more obscure.
That said, I don't feel like I'm cheating when using string mixins. I
find them a quite good substitute to AST macros. And perhaps string
mixins are simpler too: you don't have to learn a new macro syntax, you
just manipulate strings. Though I'm still waiting for the day we can
use string mixins in expressions to do things like this:
int num = 1;
string result = substitute!"Number: $num";
assert(result == "Number: 1");
--
Michel Fortin
[email protected]
http://michelf.com/