On 21 February 2012 14:13, Daniel Murphy <yebblies@nospamgmail.com> wrote:
Why can't you do that with existing language features?

alias JniExternFunc!(void function(int)) someJNIFuncYouWantToCallFromD;
mixin JniExportFunc!(&dFuncYouWantToCallUsingJNI);

Where the templates generate the wrapper code/calling convention arg shuffle
for each function.

You could, but that's really ugly. I did make the point in my OP that it can be hacked right now, but I also listed the benefits of making it a proper feature:
 1. It would be very neat and tidy. Clarity and readability is important for code longevity.
 2. Ease of refactoring/delegation to scripts without refactoring all the calling code throughout your app (this is real, I have done this on many occasions)
 3. Declaring functions in the regular way, and annotating them with various properties (const/pure/etc) allows all the usual type safety and optimisation potentials available to the language.
     As far as the compiler is concerned, it is a real and normal function call. All surrounding code gen/optimisations are still applicable, the language will simply substitute the marshalling function at the final step of the call.
 4-ish. It actually seems relatively simple to implement... and it's not a breaking change. I can't really see any down sides.