#!/usr/bin/rdmd
void main(string[] arg) {

  // Observation: I'd like to say:
  /*
  auto r = myfunc.call("named") with { z= 2; x = -123; y = 200; }
  */

  // and have it turned into this:
  with(myfunc) { x = -123; y = 200; z = -20; }
  auto r = myfunc.call("named");

// Q: is there some way to achieve this? Maybe a variation on with?

// Is there a macro facility lurking someplace? Or is there another way to do this?
  // Thanks!
  // - J
}

import std.stdio;

struct myfunc_
{
   // named keyword or named parameters
   // --the call arguments and their defaults
   int x=0;
   int y=0;
   int z=0;

   string call(string non_keyword_arg)
   {
     writefln("%s:  X %s, Y %s, Z %s", non_keyword_arg, x, y, z );
     return "yo";
   }
}
myfunc_ myfunc;

Reply via email to