Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : MMB4L: should functions/subs be allowed same names as labels?
Page 2 of 2 | |||||
Author | Message | ||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3839 |
Yes, you aren't imagining it, it's a firmware "bug" which may have been a deliberate optimisation/omission in the pre-hashmap MMBasic implementations but which could be caught for negligible cost on CMM2/PicoMite/MMB4W ... I have done so for MMB4L. Best wishes, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
toml_12953 Guru Joined: 13/02/2015 Location: United StatesPosts: 326 |
Easier fix: don't use labels, just line numbers the way BASIC was meant to be! :) Tom L - Defender of the (BASIC) Faith P.S. I used to have to check lines by hand but the computer does it now so I guess you could call me an Exchequer |
||||
Turbo46 Guru Joined: 24/12/2017 Location: AustraliaPosts: 1593 |
I'm surprised that people still use line numbers in this day and age. You can use line numbers but MMBasic doesn't honour them the way it used to. Try: 10 print 15 print "line 15" 10 print "line 10" 20 print "line 20" 15 print "line 15 too" end The lines will be processed in the order that they are typed, line 15 is not inserted between lines 10 and 20 and two line 15s are OK. Personally, particularly for the MM2, I'd be happy if Tom's original suggestion was adopted plus all of the "legacy" (Obsolete) stuff was dropped. The current version could be frozen for use by the dinosaurs and older programs and we could move on. Maybe that would allow other nice things to be added like the INC command that was discussed but went no further. Bill Keep safe. Live long and prosper. |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 5726 |
In MMBasic line numbers are treated as labels, not a program flow system. So, you can GOTO or GOSUB them. The editor is a text editor so, as you add lines with numbers it doesn't sort them into order, it merely enters them into the text area as is. Consequently lines won't be inserted in numerical order and, as MMBasic treats the numbers as labels, there is no duplicate checking. You probably *could* get rid of line numbers completely but it's probably far more fundamental to MMBasic than you might think (e.g. do you also get rid of labels? Can labels begin with a number?) and is programming effort better spent elsewhere. It's so easy simply not to use them. If you feel thet you simply *must* have line numbers that work properly then I'm afraid MMBasic isn't for you. :) There is also the idea that removing legacy stuff completely is one more step in making MMBasic more like C - an idea that is pretty unpopular, I think, as well as breaking compatibility with earlier BASIC programs. INC is as it is because of the limited number of command slots available in MMBasic. Not only does "INC a,-1" work ok (and doesn't look too bad) it takes one command slot less than "DEC a" and can be worked around with "a=a-1" anyway unless you really need the speed. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 5903 |
No Jim Edited 2023-01-31 19:14 by TassyJim VK7JH MMedit MMBasic Help |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 5726 |
The point I was trying to put over, Jim, is that if you remove the capability of using line numbers what breaks? Are lines beginning with a number then assumed to have a label (unlike now)? Would you have to check every line to ensure that all lines began with an alphabetic, "'" or "?"? The way line numbers are currently implemented is, I suspect, at pretty low level in MMBasic and it would be serious work to remove them - probably even harder to make them work "properly" as that would mean major changes to the editor. Far easier to simply ignore them. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3839 |
Under the hood I wouldn't have said that is strictly true, but close enough . I read, here or elsewhere, that one of the principle reasons for line numbers in early BASICs as opposed to labels was so that you could get away with a very simple "line editor" that didn't require any significant editing or navigation capabilities, you enter a line with a number and it inserts itself into the correct place in the program or overwrites the existing line with the same number. I'm not sure it's that fundamental. I think that there is still quite a big difference between MMBasic without line numbers, GOSUB and RESTORE and "C" (note I wouldn't remove GOTO <label>, it has its place even in structured programming, Dijkstra can come round to my gaff and fight it out if he wants). But I have no wish to fracture an already niche community even though I doubt anyone would have noticed my suggestion had I implemented it ... and I still might. I think it is possible that Bill was bemoaning the lack of INC on the MM2, AFAIK it's only available on Peter's ports and MMB4L. Best wishes, Tom Edited 2023-01-31 21:10 by thwill Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3657 |
Exactly. Ooh, be careful what you wish for! (Monkey's paw anyone?) John Edited 2023-01-31 19:54 by JohnS |
||||
robert.rozee Guru Joined: 31/12/2012 Location: New ZealandPosts: 2287 |
one could start an interesting thread: "with what we know now, how would we design and implement MMbasic today?" not that i would seriously advocate this, just that it is an interesting thought experiment. i am reasonably confident that even if 're-imagined', the final result would probably run at a similar speed, use similar memory resources, and have similar ease of use. having said this, i can see merits in refactoring the existing source code, if for nothing else than to allow a wider range of forum members to become familiar with the source; we need to reduce the average age of 'keepers of the code'! cheers, rob :-) |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 5726 |
The PicoMite source is available for download. It's not secret. :) You're even allowed to modify it if you want to, with certain conditions. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8579 |
Yes for well over a year now as is MMB4W. And no-one, with the sole exception of Tom, has contributed a single line of code |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3839 |
Hi Peter, I might get grief for this, but I don't deserve it, I'm doing everything I personally can, but here goes ... Let's for the sake of argument assume that there are other people interested and capable (ability AND time) of contributing ... and I suspect that is quite a big assumption. There are at least 3 hurdles that you don't want to hear about: * GitHub - you're basically using it as "drop-box": there are no "atomic commits" just "dumps", no proper commit messages (just endless "Add files via upload"), no use of its issue tracking, versioning or release artifact features. * There isn't a single shared code-base/repository for PicoMite, PicoMiteVGA and MMB4W (or for that matter MMB4L - I'm just as guilty of ploughing my own furrow in this respect), they are all proceeding in parallel and require manual intervention to synchronise (or not). * And finally, open source purists will still be "sniffy" about the additional terms in the license. None of this is "easy s**t", and please don't think I expect you to resolve any of it - it's not like I'm going to either. You are, I imagine interested in "messing about" with "hobbyist" electronics, micro-controllers and bits and pieces of programming, not reliving your career of trying to herd cats. In conclusion, we are where we are, someone else might come along and "muck in", which is presumably how you started, and like I am now trying to do, but I won't be holding my breath for contributions and I'll be trying to contain my exasperation at the sisyphean nature of the task. With the greatest of respect, and please don't shoot the messenger, Tom Edited 2023-02-01 00:54 by thwill Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3657 |
Yes for well over a year now as is MMB4W. And no-one, with the sole exception of Tom, has contributed a single line of code It's good it's available. I got as far as building it, modifying it, and testing to find out more about the signon-message issue & USB (just under a year ago). Not a criticism but a reality: it helps to be fairly happy with C/C++ and toolchains etc... I don't know how many people here are up for it (I hope more than I know) - but have a go people! Ask for help if you get stuck. I've not found a line of code I felt I ought to push to be changed, but then at the time I wasn't looking for any unless the testing hit something specific. I've got as far as puzzling how some parts do (or should) work (such as Tom's recent posts about saving/restoring context). I couldn't have done that without the source. On reading the source, Tom's suggestions looked right and the code somewhat in need of the fix he put forward. John Edited 2023-02-01 01:46 by JohnS |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3839 |
Addendum: I think everyone contributes here: MMBasic programs/projects, tools, ideas, opinions or even just to the entertainment. Best wishes, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 5726 |
In spite of eventually buying an Arduino in the hope that some C++ (or whatever it is) would finally wash off on me if I played with it I still have great difficulty in following even the simplest of routines in it. TBH I even get stuck at void( sometimes and have to go and look it up. I've now given up on it and shoved the Arduino in a box somewhere. It might see the light of day eventually, but not until I get a PC that can handle the vile IDE. I'm afraid my chances of understanding the PicoMite code are next door to zero! I'd never heard of a "toolchain" until Peter mentioned it in one of his posts some time ago. I'm still not sure what one is or if I need one. :) Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3657 |
Typically compiler & linker. May well also include an assembler. Frequently for cross-platform use, e.g. build Picomite sources on a nice fast PC and end up with the UF2 file. So, you're using (say) x86_64 host to build ARM code for the Pico. (Arduino development using a PC is another case, the target being a Mega or Uno or ...) Probably the most well-known toolchain is based on gcc (GNU C compiler, with its associated assembler, linker, etc). John Edited 2023-02-01 03:32 by JohnS |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 5726 |
Ah... I've heard of gcc. I came across that while I was running linux. :) Thanks, John. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3657 |
Thanks, John. Also available for Windows. John |
||||
Turbo46 Guru Joined: 24/12/2017 Location: AustraliaPosts: 1593 |
Correct. I also avoid the use of GOTO. I still have bad memories of trying to convert the Pirate adventure to MMBasic for the 'Welcome tape'. 93 GOTOs and no, that is not an exaggeration, 93 GOTOs. That was too much for my tiny brain to unravel. Line numbers may not be true labels but as a target for GOTO and GOSUB they do a fair imitation. I would get rid of them and some of the 'obsolete' commands. For what it's worth that is said by someone who has no idea what that would involve and is not in the slightest bit capable of 'mucking in' to do it myself. Bill Keep safe. Live long and prosper. |
||||
Page 2 of 2 |
Print this page |