Passing refs with delegates
Mark J Twain via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Aug 2 19:55:58 PDT 2016
It's nice to be able to pass delegates and functions as callbacks.
A nice feature is something like
R foo(R,Args...)(R function(Args) callback, Args args) { return
callback(args); }
There are two problems with this.
One is that type deduction doesn't work. I have to explicitly
specify the types of args. This creates a lot of verbosity.
Second, I can't pass ref parameters. The usefulness of this
method is that it sort of lets you pass data in and out of the
callback, all defined by the user calling foo. Sometimes you want
to pass in references to store data and other times you don't.
Is this a bug in D's type checking system or unfinished work or
simply nonsense?
right now I pass in pointers, but that doesn't work to well for
some types, and is messy.
More information about the Digitalmars-d-learn
mailing list