I do agree that numerical calls with floating point numbers could be useful to avoid having to convert to and from a string, though I'm not sure how feasible that would be to setup. Presumably we'd need some kind of way to differentiate between what kinds of data are expected for which functions.
Being able to use DLL functions that return floating point numbers would be very useful, because we would avoid the conversion to and from a string.
The current DLL function signature we are allowed to use is the following:
extern "C" char *func(int argc, char *argv[])
// argc = #arguments, argv[] = array of arguments
The current format for using the call proc to access the functions of a DLL is as follows:
Format:
call(LibName,FuncName)(Arguments)
Args:
LibName: name of external library ("test.DLL")
FuncName: name of function in external library ("func")
My suggestion is the following:
Format:
call(LibName,FuncName,FuncSig=LIBFUNCSIG_STRING)(Arguments)
Args:
LibName: name of external library ("test.DLL")
FuncName: name of function in external library ("func")
FuncSig: LIBFUNC_STRING or LIBFUNC_NUMBER
This adds a third argument to the call proc that tells it to assume a certain function signature.
The other signature I propose is:
extern "C" float func(int argc, float argv[])
// argc = #arguments, argv[] = array of arguments
A new signature that takes an array of floats as input and returns a float as output.
This won't break existing, working DM code with shared libraries, and can easily be extended to include other signatures if need be. (If desired, it could even include a fourth argument for the call proc, and use the two new arguments to determine both input and output types.)
To make a reference back to a topic that discussed this earlier (and I see you've made a forward reference to here from ...):
http://www.byond.com/ forum/?post=675792&hl=dll#comment1863839
This does carry binary compatibility to older DLLs/SOs (although in my experience, many of the DLL/SO developers are still around, and can update), but probably makes the dynamic linker throw a fit at older DLLs/SOs. The interface is not one BYOND should be afraid of breaking however, in the interest of "getting it right", as the current value of our library set that uses DLLs/SOs, to the general developer-base is quite small, mostly I think for deployment and dev testing reasons (no linker inclusion of library directories / copying of the DLL into your project etc).
What I propose instead, is you and I have a chat together about DLL/SO based libraries in general, and put together a more all encompassing feature request, that provides a minimal effort plan to making DLL/SO based libraries useful, and accessible to BYOND developers as a whole. Discussions about improvements to provided / return types is nice, but it's only really part of the issue.