this is almost a workaround for the lack of named parameters

J not_avail at notavailable.com
Thu Mar 21 13:42:32 PDT 2013


On Thursday, 21 March 2013 at 19:59:01 UTC, Jacob Carlborg wrote:
> On 2013-03-21 19:35, J wrote:
>
> Here's another workaround: 
> https://github.com/jacob-carlborg/mambo/blob/master/mambo/util/Reflection.d#L135

Intriguing, Jacob!  I could learn alot about reflection by 
studying your code.

How is it installed?  I installing by downloading that single 
file, and with a quick hack to the Reflection.d top three lines 
(commenting out the module and imports at the top), I tried 
calling it with this, no luck:

#!/usr/bin/rdmd

import Reflection; // with module and imports commented out...
import std.stdio;

string my(int a, int b) {
   writeln(a/b);
   return "howdy";
}

void main(string[] arg) {

    auto s = callWithNamedArguments(my, `a=3, b=4`);
}

// yields:

$ ./ref.d
./ref.d(13): Error: function ref.my (int a, int b) is not 
callable using argument types ()
./ref.d(13): Error: expected 2 function arguments, not 0


More information about the Digitalmars-d mailing list