BBC BASIC with objects?
Alex Farlie (144) 35 posts |
Is anyone looking into adding OO features into the released BBC Basic Sources? I would be interested to hear more on what synatx was finally decided if it is :) |
Steve Revill (20) 1361 posts |
You should probably look at either BasAlt or BBC BASIC for Windows. I think either or both of these have some form of support for objects at least. Not sure how far down the road anyone has gone with OO but I suspect it would be a waste of time trying to add that kind of thing to our BASIC module. It’d probably be a damn site easier to write a BASIC interpreter in C which has a BASIC-like syntax, if you ask me. Any changes to the existing BASIC would be more sensibly things like removing the 255 char limit on strings, dynamic memory allocation and structures. |
Alex Farlie (144) 35 posts |
Understood. Myself, I would welcome a rewrite of ARM Basic in ‘C’ if someone was inclined, and might be a ‘better’ approach to adding new features, including for example the use of ‘DIM PTR’ to support a pointer variable extension like that in Pascal :) Do you happen to have a specification for the current version of ARM Basic that’s shareable? The spec would be something like : The Token Table The BNF grammer Operator Ladder Pusedo variables.. Structures would require some handling of constructions involving “{}” and an extension of the DIM command handling. It would also be a wise move to reserve the ”->” operator be reserved, in relation to structures. This operator would have the same functioning as in C in terms of structures. Like BBC Basic on the BBC I am assuming ARM basic doesn’t normally talk to Hardware? (i.E all OS-System interaction is handled via SWI’s?) |
GavinWraith (26) 1563 posts |
Modifications to Basic would obviously have to be backward compatible. But in my opinion, the problems of Basic do not lie on the surface but in what might be called its deeper layers – the fact that the only way to implement complex datatypes is by DIMing arrays and using pointers, that functions cannot be passed as parameters or returned as results, that a function can only return one value at a time, no coroutines, etc. These structural deficiencies do not just cramp the programmer’s ability to express herself – they can cramp her very mental picture of what programming solutions are possible, which I think is what Edsger Dijkstra was getting at with his notorious remarks about Basic. Alex talks of “adding OO features”. The problem is not so much “which features” as “which OO”. There are dozens of OO languages that are all different in their interpretation of what OO means. Do you have classes or do you have prototypes? What kind of inheritance mechanisms? Static or dynamic typing? You have only to look at C++ to see what a dog’s breakfast (sorry there Bjarne!) you can end up with by trying to tack on fundamental changes to a language. Personally, I have always found the OO paradigm rather confusing. It was only when I looked at the C sources of Bob that I began to get some mental picture of what OO terminology meant (e.g. what is the difference between a static and a private property of a class) – and that was only one implementation out of many. I have spent many years pondering the role of Basic in RISC OS, and how it might be possible to keep the advantages brought by its close ties with how RISC OS SWIs expect data to be passed in, and at the same time have the benefit of newer programming paradigms. My first attempt was ArmBob, but that never took off. My second was RiscLua, which I think is much better as a language, though how many people actually use it is another matter. Lua is not an OO language, by design, but it offers the possibility of letting the programmer implement any type of OO feature, with its metaprogramming facilities. To descend from my hobbyhorse for a second, one small extra feature could be very useful for Basic: the possibility of declaring a variable or FN/PROC to be local to a library – like static variables in C. Basic’s scoping facilities are very limited. FN/PROC bodies are the only constructs to which scope can be made local. It would be useful to have scopes restrictable also to FOR .. NEXT, WHILE .. ENDWHILE, REPEAT .. UNTIL , IF .. ENDIF blocks. |
Chris (121) 472 posts |
While, as a BASIC programmer, many of these suggestions sound welcome and valuable, I can’t help thinking that the scarce developer time we have would be better spent on other things. After all, we have access to C, C++, Lua, Python, and probably other languages if we want. BASIC remains useful as a scripting language even with its current limitations. Of course, that raises the question of what projects would be a higher priority. In the absence of any ‘master plan’ from ROOL, this is of course open to conjecture. But I would certainly prefer to see an overhaul of the file system to allow big files and better support for industry standard storage media (HDDs, CDs, DVDs, USB devices) as a first step, so I hope Alex Waugh’s proposals get some support. |