On 21 February 2012 14:33, Iain Buclaw <ibuc...@ubuntu.com> wrote: > On 21 February 2012 11:03, Manu <turkey...@gmail.com> wrote: > > So I was thinking about this extern(language) thing, the obvious ones are > > supported, but it would be really nice to be able to implement custom > > conventions for other languages/scripting languages. > > > > For instance, I'm thinking about Android, I have JNI binding code > > everywhere, it's really ugly. > > I'd love to be able to declare: > > extern(Java) int someJavaFunc(int x, float y) > > > > And then use my function like any regular function, with the > 'extern(Java)' > > bit handling the JNI business behind the scenes. > > I also regularly interact with javascript, lua, C#/mono, and these could > all > > be implemented the same way. > > > > I'm imaging some mechanism to declare a calling convention (which would > be > > resolved within the extern(...) statement), and define it with a > template, > > something like: > > > > Or you could just define extern(Java). > > SDC made a start at this, gdc could implement this using the same as > g++'s extern "Java" interface to gcj (we would only be JNI compatible > with gcj though). >
Java was just my example, but it'd be nice to have this option for all external languages I regularly bind to. Also, I don't see why hard coded language support for extern(Java) is actually necessary if it were implemented in a flexible way instead.