Any chance of CALL being implemented?
Attempting to use the CALL statement results in an Unsupported BASIC V/VI feature found error, but evidently it's not entirely absent because CALL with no parameters results in Syntax error and CALL "string" results in Type mismatch: number wanted. So some parsing of parameters, at least, is present in Brandy.
Presumably the reason CALL isn't fully implemented is that there's no assembler, and CALL is most commonly used to call an assembled routine. But it need not be used for that purpose, it could perfectly well be used to call a function compiled from C (for example in a DLL or other Shared Object) as an alternative to SYS.
Indeed in BBC BASIC for SDL 2.0 CALL is used in exactly that way to support sorting on those platforms which don't have a working assembler (e.g. iOS and Emscripten). The advantage of CALL over SYS is that the parameters are passed as both a pointer and a type; there's no way of discovering the parameter's type when using SYS.
If CALL was implemented in Matrix Brandy it would make it possible to support sorting in an elegant way, potentially even compatible with the existing sortlib libraries for BB4W, BBCSDL and BBCTTY.
Presumably the reason CALL isn't fully implemented is that there's no assembler, and CALL is most commonly used to call an assembled routine. But it need not be used for that purpose, it could perfectly well be used to call a function compiled from C (for example in a DLL or other Shared Object) as an alternative to SYS.
Indeed in BBC BASIC for SDL 2.0 CALL is used in exactly that way to support sorting on those platforms which don't have a working assembler (e.g. iOS and Emscripten). The advantage of CALL over SYS is that the parameters are passed as both a pointer and a type; there's no way of discovering the parameter's type when using SYS.
If CALL was implemented in Matrix Brandy it would make it possible to support sorting in an elegant way, potentially even compatible with the existing sortlib libraries for BB4W, BBCSDL and BBCTTY.
0
Comments
-
Currently CALL is only implemented for calling the classic MOS routines, e.g. A%=0: CALL &FFF4 will perform a *FX0.
Matrix Brandy already has the means to call routines from a shared library (though, largely untested in Windows), with SYS calls "Brandy_dlopen" and "Brandy_dlcall". These are listed in docs/sys-calls.txt.0 -
Matrix Brandy already has the means to call routines from a shared library (though, largely untested in Windows), with SYS calls "Brandy_dlopen" and "Brandy_dlcall"
Are you suggesting that's not correct? Is there a way of using SYS such that the parameters' types can be discovered by the called routine, as well as their pointers? That would be great, and should allow a sorting library to be written, but it's not something I was aware of.
0 -
Not saying that's incorrect, just that for CALL, the implementation is minimal, just enough to support calling the old MOS calls.
It is something I could look at, using the address of a library routine obtained by SYS"Brandy_dlgetaddr".0 -
Not saying that's incorrect, just that for CALL, the implementation is minimal, just enough to support calling the old MOS calls.
0