<div class="gmail_quote">On 21 February 2012 14:13, Daniel Murphy <span dir="ltr"><<a href="mailto:yebblies@nospamgmail.com">yebblies@nospamgmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Why can't you do that with existing language features?<br>
<br>
alias JniExternFunc!(void function(int)) someJNIFuncYouWantToCallFromD;<br>
mixin JniExportFunc!(&dFuncYouWantToCallUsingJNI);<br>
<br>
Where the templates generate the wrapper code/calling convention arg shuffle<br>
for each function.<br></blockquote><div><br></div><div>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:</div>
<div> 1. It would be very neat and tidy. Clarity and readability is important for code longevity.</div><div> 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)</div>
<div> 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.</div><div>     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.</div>
<div> 4-ish. It actually seems relatively simple to implement... and it's not a breaking change. I can't really see any down sides.</div></div>