Macros. Back in my assembly language days, macro's were a useful feature and supported by the assembler/compiler. You could define a chunk of code in one place and then `insert` that code at any place by just calling the macro. And of course you could have nested macro's, and also conditional macro's using If-Then-Else stuff. Presumably this was more useful for assembler code since it was so low-level, the trend was towards fast in-lined code and because asm programs could be so long and complicated.
Well anway, I thought macros would be a nice addition to either the BlitzMax IDE (or another IDE such as Protean - haven't tried it or checked if it does this), or to the BlitzMax compiler (or as a pre-compiler?). This would then allow the programmer to maintain a piece of code in one place that can be in-lined wherever needed. It's a different way to go about things rather than lots of function calls.
I'm a little concerned with the fact that BlitzMax is abstracted from the hardware as it is. In other words, in order to implement a lot of functionality, a lot of it is written IN BlitzMax, and a lot of the functions call other BlitzMax functions themselves. This is adding extra overhead and distancing the user from the raw hardware. It's all very well abstracting things and making it higher level but there is a speed expense. And now I also see people throwing around the idea of creating a `wrapper` module like nobody's business, even though that will likely add yet more layers of nested function calls.
With macro's you would be able to easily in-line code and functionality rather than needing to make more calls to a stack. One idea I came up with to temporarily work around this is if you wanted to rename some of the tokens .... you could create a piece of code to define function pointers which you then proceed to re-map to the actual functions you want them to call, at runtime, before they are called. You could then use these re-named tokens in your programming (unless I overlooked some compiler issue). For example you could then use different wording for the OpenGL commands if you wanted to (some of them are not labelled entirely to my liking). This techinique would at least give you a limited piece of the functionality that macros would give you, and for such an application you wouldn't need to create yet another module that only ends up calling a function from within a function. Looking through the BlitzMax modules there's several instances where you call something that just calls something else which calls something else, all different names. No needed.
But anyway. How about macro functionality for BlitzMax programs?
Well anway, I thought macros would be a nice addition to either the BlitzMax IDE (or another IDE such as Protean - haven't tried it or checked if it does this), or to the BlitzMax compiler (or as a pre-compiler?). This would then allow the programmer to maintain a piece of code in one place that can be in-lined wherever needed. It's a different way to go about things rather than lots of function calls.
I'm a little concerned with the fact that BlitzMax is abstracted from the hardware as it is. In other words, in order to implement a lot of functionality, a lot of it is written IN BlitzMax, and a lot of the functions call other BlitzMax functions themselves. This is adding extra overhead and distancing the user from the raw hardware. It's all very well abstracting things and making it higher level but there is a speed expense. And now I also see people throwing around the idea of creating a `wrapper` module like nobody's business, even though that will likely add yet more layers of nested function calls.
With macro's you would be able to easily in-line code and functionality rather than needing to make more calls to a stack. One idea I came up with to temporarily work around this is if you wanted to rename some of the tokens .... you could create a piece of code to define function pointers which you then proceed to re-map to the actual functions you want them to call, at runtime, before they are called. You could then use these re-named tokens in your programming (unless I overlooked some compiler issue). For example you could then use different wording for the OpenGL commands if you wanted to (some of them are not labelled entirely to my liking). This techinique would at least give you a limited piece of the functionality that macros would give you, and for such an application you wouldn't need to create yet another module that only ends up calling a function from within a function. Looking through the BlitzMax modules there's several instances where you call something that just calls something else which calls something else, all different names. No needed.
But anyway. How about macro functionality for BlitzMax programs?