<div class="gmail_quote">On 21 February 2012 13:19, Gor Gyolchanyan <span dir="ltr"><<a href="mailto:gor.f.gyolchanyan@gmail.com">gor.f.gyolchanyan@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This is just what I needed. I need to create a new calling convention<br>
to implement dynamic data typing without resorting to incredibly slow<br>
and cumbersome Variant.<br></blockquote><div><br></div><div>Umm, I am of course talking about a compile-time feature.</div><div>I believe you'd have to use some sort of variant behind there if you wanted to make dynamically typed calls...</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On Tue, Feb 21, 2012 at 3:03 PM, Manu <<a href="mailto:turkeyman@gmail.com">turkeyman@gmail.com</a>> wrote:<br>
> So I was thinking about this extern(language) thing, the obvious ones are<br>
> supported, but it would be really nice to be able to implement custom<br>
> conventions for other languages/scripting languages.<br>
><br>
> For instance, I'm thinking about Android, I have JNI binding code<br>
> everywhere, it's really ugly.<br>
> I'd love to be able to declare:<br>
>   extern(Java) int someJavaFunc(int x, float y)<br>
><br>
> And then use my function like any regular function, with the 'extern(Java)'<br>
> bit handling the JNI business behind the scenes.<br>
> I also regularly interact with javascript, lua, C#/mono, and these could all<br>
> be implemented the same way.<br>
><br>
> I'm imaging some mechanism to declare a calling convention (which would be<br>
> resolved within the extern(...) statement), and define it with a template,<br>
> something like:<br>
><br>
> callconv Java<br>
> {<br>
>   R call(T...)<br>
>   {<br>
>     // process tuple of args, make the call, return something?<br>
>   }<br>
><br>
>   R thisCall(Class, T...)<br>
>   {<br>
>     // also need a way to implementing methods... this might be enough.<br>
>   }<br>
> }<br>
><br>
> Some fancy code in there could conceivably call into any foreign language,<br>
> and this would be great!<br>
> Now when I: import java.jni;<br>
> I have the jni interface, but I also have access to extern(Java), and that's<br>
> awesome! :)<br>
><br>
> The main benefit over using a template, for<br>
> instance: jniCall!"functionName"(args...), would be the function name is not<br>
> a string, or require custom code construct (facilitating later re-factoring<br>
> or delegation to script without changing masses of existing code, something<br>
> I have done often), and if it was seen by the language as a regular function<br>
> call, you can mark it with all the usual stuff, const/pure/etc, and apply<br>
> the expected set of optimisations to the call.<br>
><br>
> I'm sure this has been discussed before... so go on, tear it apart :)<br>
<br>
<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
Bye,<br>
Gor Gyolchanyan.<br>
</font></span></blockquote></div><br>