opIndexCall
    Jarrett Billingsley 
    kb3ctd2 at yahoo.com
       
    Sat Mar 24 21:25:10 PDT 2007
    
    
  
"Dan" <murpsoft at hotmail.com> wrote in message 
news:eu4man$1cs3$1 at digitalmars.com...
>
> Heh...
>
> the code was a sample, not my actual code (obviously)  I was trying to 
> only show enough to represent what I was trying to suggest.
>
> That said, I was hoping we could do:
>
> myAssocStruct[myCharArray](params)
>
> Which I've never seen done before in D in any examples or source online, 
> or in the guide.  I haven't actually tried a minimal test case, I just 
> didn't know the feature existed at all and was suggesting we ought to be 
> able to do so.
>
> If we can, then hey... I'll try to figure it out then.  : p
Uhh, well:
struct FuncHolder
{
    void function(int)[char[]] funcs;
    void function(int) opIndex(char[] name)
    {
        return funcs[name];
    }
    void opIndexAssign(void function(int) func, char[] name)
    {
        funcs[name] = func;
    }
}
void foo(int x)
{
    writefln("foo: ", x);
}
void bar(int x)
{
    writefln("bar: ", x);
}
void main()
{
    FuncHolder fh;
    fh["foo"] = &foo;
    fh["bar"] = &bar;
    fh["foo"](3);
    fh["bar"](4);
}
Unless you're getting at something else? 
    
    
More information about the Digitalmars-d
mailing list