New idea for feature re: object use
T Chap
Posts: 4,223
What about an application or feature in BST or Proptool that allows the user to merge objects into a single main program, versus using a main program that has to work with a lot of objects? Upon a special compile mode, everything becomes one big file containing the objects methods. The benefit being that there would be no more need for pointers, and cog sharing hassles, simply use the same variables between all cogs. In the future if a separate object gets modified, the special compile just replaces the contents in the main 'merged' method with the updated contents from the objects SPIN file, so that the main program goes out, compares and if there is a changed object file, bring in the changes. If there are new methods added to the OBJ, merge in the new methods.
Obviously this would require that some objects get modified to no longer required pointers (if necessary), but I think this would be a very useful system. In this way of thinking, you still have object files that can be used in other projects, but the main program is much simpler as a single standalone program.
Obviously this would require that some objects get modified to no longer required pointers (if necessary), but I think this would be a very useful system. In this way of thinking, you still have object files that can be used in other projects, but the main program is much simpler as a single standalone program.
Comments
Another advantage of objects and the hiding of names is that you can have two objects that appear functionally to be identical. They have the same public methods and they define the same constants, but they're implemented completely differently inside. They have different variables, different amounts of variable space, different private methods that do somewhat different things, yet appear to the outside world to be identical. For example, one implementation might be relatively slow, but very efficient in terms of space used. The other implementation might be very fast, but a hog in terms of memory use.
Still, there are cases where merging code from files is useful: PASM source or DAT sections that would contain bit-map sections for example.
Having to copy PASM code by hand from one file to another is painful and error prone.
If one could include source into a DAT section with a directive (file is not good enough), merging PASM source among files would be so much easier. It is possible to do this today with an existing third-party tool (cpp for cygwin/linux), but this makes the source messy and the tools are not easily available to most windows users.
Cheers.
Homespun is a 3rd party command line Spin compiler / PASM assembler that is cross platform (Windows / Linux / MacOS) and has the conditional compilation along with simple macros (here).
BST is another 3rd party Spin compiler / PASM assembler that includes an IDE although does come in a command line version. It has much the same features as Homespun plus a few of its own (here). I use BST under the MacOS for all my Propeller development.
Neither one has an "#include" statement at present.
Some features of the text editor:
The app will look at a folder to see if a file is present with the method name, if not, it creates a file there with the method name for future use.
If you modify a method in the main program, you have an option to update the raw external method file.
Upon compile, the main program will look at the raw external method files, compare, and load in the external version as a default, probably with a warning and options to skip, update the external with the current method.