A Perspective on D from game industry

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Mon Jun 16 08:05:29 PDT 2014


On Mon, Jun 16, 2014 at 12:44:05PM +0000, via Digitalmars-d wrote:
> On Monday, 16 June 2014 at 11:49:11 UTC, Rikki Cattermole wrote:
> >I would go that far, when combining string mixins,
> 
> As far as I can tell string mixins have the same bad properties that
> macros have. It makes automatic translation very difficult and makes
> reasoning about code more difficult. It is a cheap and effective
> solution, but without any trace of beauty... A design blunder IMHO.

Actually, IIRC, string mixins were never designed to be nice -- they
started as a kind of temporary last-resort kludge that got put in, in
lieu of a true AST macro system, with the view that it would meet the
current metaprogramming needs until the latter, ostensibly superior,
solution came along.  Unfortunately, AST macros never happened, and
string mixins kinda took hold in the D codebase, so that's what we have
now.

I would personally avoid using string mixins unless there's absolutely
no other way to achieve what you want -- they're a kind of last-resort
nuclear warhead that you don't bring out unless all the other guns fail
to win the battle.

Having said that, though, proper use of string mixins with CTFE and
templates ('scuse me, *compile-time arguments* ;)) can be extremely
powerful, and one of the things that make D metaprogramming so awesome.


T

-- 
"The whole problem with the world is that fools and fanatics are always so certain of themselves, but wiser people so full of doubts." -- Bertrand Russell. "How come he didn't put 'I think' at the end of it?" -- Anonymous


More information about the Digitalmars-d mailing list