opMixin or mixin function templates with convenience operator?

H. S. Teoh hsteoh at quickfur.ath.cx
Thu Dec 12 17:19:35 UTC 2019

On Thu, Dec 12, 2019 at 04:53:36PM +0000, bachmeier via Digitalmars-d wrote:
> On Thursday, 12 December 2019 at 11:48:47 UTC, Zoadian wrote:
> > I'm all in favor of improving D meta programming to the point we can
> > express stuff like string interpolation in library code because it
> > might allow for other new cool stuff we were not able to do before.
> I'm not, because you'll drive away large numbers of potential users.
> Metaprogramming might be cool, but you need to keep it under control
> because it can make the complexity of learning and using the language
> explode.

Wut...?!  The primary reason I'm using D is *because* of metaprogramming
features.  It's one of the things about D that stands out above other
languages and differentiates it from them.  For me, it's one of the
important things that make it worth using D in spite of whatever other
flaws D may have.

Adam is currently working on a Java<->D glue library via JNI, which is
turning out to be *extremely* nice: you just declare a class and
annotate its methods with @Import and @Export, and it automagically
creates JNI glue code, creates the right mangling, handles type
conversions, etc., and you can call Java code from D directly (and vice
versa).  You don't even need to do anything special (other than link
with the JNI interface library of your chosen JVM) to make this work;
just "import arsd.jni", derive your class from the provided template
base class, and start calling Java methods like they were native D code.

The core of this library is some powerful metaprogramming not found in
any other language to my knowledge.  Compile-time introspection, static
foreach, UDAs, and pragma(mangle) all come together in one powerful
package that completely automates what in any other language would have
required truckloads of boilerplate and awkward external code generation
tools. In D, the entire implementation sits in a single .d file.

Bring on the metaprogramming, I say.  Make string interpolation another
powerful tool in the metaprogramming toolbox, and take D to a whole new
level of awesome.  We should be embracing and honing metaprogramming in
D, not shying away from it!


"You are a very disagreeable person." "NO."

More information about the Digitalmars-d mailing list