June 26, 2015
On Friday, 26 June 2015 at 16:57:14 UTC, Charles Hawkins wrote:
> Sorry for talking to myself, but I'm hoping someone will help me out.  The above idea doesn't work.  It appears that only the main program file is going to have function pointers while modules and classes will have delegates.  So, does a library that uses callbacks need 2 callback register functions as well as parallel storage mechanisms, or is there a fairly simple way to make it polymorphic?  I was hoping a newbie would be able to use this library, but not many newbies are going to understand this.  I suppose I could tell them to call registerFunction and if they get a compiler error, then call registerDelegate?  Or am I missing something?

I don't fully understand what you're doing, but functions can easily be turned into delegates using std.functional.toDelegate [1]:

    import std.functional : toDelegate;
    registerDelegate((&topLevelFunction).toDelegate);

[1] http://dlang.org/phobos/std_functional.html#.toDelegate
June 27, 2015
On Friday, 26 June 2015 at 17:11:54 UTC, Marc Schütz wrote:
> On Friday, 26 June 2015 at 16:57:14 UTC, Charles Hawkins wrote:
>>[...]
>
> I don't fully understand what you're doing, but functions can easily be turned into delegates using std.functional.toDelegate [1]:
>
>     import std.functional : toDelegate;
>     registerDelegate((&topLevelFunction).toDelegate);
>
> [1] http://dlang.org/phobos/std_functional.html#.toDelegate

Thanks, Marc.  That should work if my brute force duplicate code doesn't.

Thanks to everyone, at long last my project compiles with dmd.  It crashes right away, but that's not unexpected since I haven't used pointers in several years.  Unfortunately, compiling with gdc spits out a bunch of errors regarding getopt so I'm back to sprinkling log statements to find the problem.
1 2 3
Next ›   Last »