BASIC development
Pages: 1 2
Steve Fryatt (216) 2105 posts |
Which specifically did not work for installing the 32-bit SharedCLibrary, because it needed to be installed deeper into !Boot than the System or Boot merges could handle. The archive from Castle’s site contained an Obey file alongside the mergeable !System resource (cunningly and confusingly named !SysMerge, IIRC) which you had to double-click instead. The fun bit was that if you ignored this Obey file (ie. you didn’t RTFM that came with the upgrade) and just merged the supplied !System as normal, it seemed to work but left you with a system where the 32-bit version of the SCL got loaded “on demand”. In other words, precisely the situation that needs to be avoided for safety… |
Theo Markettos (89) 919 posts |
Would I use them? Probably not that much, because most of my scripting is in python these days as the libraries are far better (chicken and egg). I’m looking at the binary of the StrongHelp manual as I’m not near a RISC OS machine at the moment, which makes it a bit hard to read and I might be missing some things. I’m not sure about the PROCc{..} form for assignment, that feels a bit clumsy, though I like the multiple, named, assignment in one statement. Also I think you’d need a structure copy since there’s no BASIC equivalent of memcpy() to do it for us. How do you do pointers to other structures? I can’t work out how to do a linked list, for example. Can you define structures that contain pointers to other instances of the same type? |
Steve Drain (222) 1620 posts |
It is not a question of can but may.
Which is not what you said first:
|
Steve Drain (222) 1620 posts |
@Theo Some things might be clearer if you could read the manual in full, but I should emphasise that this BASIC library is a packed up set of routines I wrote to test how things might work in Basalt. It could be used, but it was really to promote comments. If you have a copy of the Basalt SH manual you could reveal the actual syntax I would use. Find the ‘Features > Concepts new to BASIC’ page and edit it to remove the comment on the ‘Structures’ link. Re-open the page and you can then find the description. Essentially:
There are several variable types, including structures. There is a Basalt equivalent of memcpy(): BLOCK TO ;-) Substructures can be defined within a structure and can be written to, or there can be a pointer to another structure that can only be read, as it may be shared. A prototype can be applied to an existing block of memory by prefixing it with the handle. I have not really considered linked lists as such, but you can link to another struct of the same type, yes. |
Rick Murray (539) 13840 posts |
I was comparing like with like – 5 byte (single?) accuracy FP in BASIC with the same thing in the emulated FP module. The 8 byte (double?) of BASIC VI should be comparable to the same in FPE; but the two different types will logically not run at the same speed as each other because one has more work to do than the other… |
Steve Drain (222) 1620 posts |
I have eventually got arround to releasing Basalt version 1.65 beta, which implements structures in the way I indicated above. A hiccup when backing up put my source files in a bit of a mess, which delayed me, even though I did not seem to loose any actual code. It may still be best to be wary of any errors that may have crept in. There are a number of other bits in this release, too. Comments are always welcome
The Basalt module can be downloaded from: http://www.kappa.me.uk/Modules/swBasalt.zipThe comprehensive StrongHelp manual can be downloaded separately from: http://www.kappa.me.uk/StrongHelp/shBasalt.zip |
Rick Murray (539) 13840 posts |
Brilliant way to handwave bugs. <stupid smirk>
Bit array is nice – might come in useful when talking to devices. What’s the difference (briefly) between string, buffered string, and indirected string?
Is it possible to point at something and say “this is a structure”? For instance, if I have a routine that reads CPUID, can I say "this variable points to data I want you to consider a structure), like:
…the difference being the “NEW” statement has a specifier of a location so instead of creating an allocating a new struct, it will point the struct reference to the existing memory (it would therefore be obvious that you can’t then Is that sort of thing supported, or can you only access structs you have explicitly created?
Now this I like. I use liberal line spacing a lot in C to make things clear and readable. I would use it more in VB5 but sometimes the auto-formatter wets itself and the results are… well… I like the sound of a way to break out of loops early if necessary. All in all, looking good! ;-) |
Steve Drain (222) 1620 posts |
Precisely that, after my mix-up. ;-)
Well, you could read the manual. A string is a normal BASIC string, a 5-byte string information block (SIB) with memory managed via the string allocation table (SAT). A buffered string is stored in a block of fixed size in the structure memory and truncated to fit. A typical use might be an icon name of 11 bytes in an icon block. An indirected string is stored as a pointer to an external block. A typical use might be a validation string in an icon block.
A closer look at what I posted would reveal
However, your comment has reminded me that such a structure is not protected from the DELETE keyword.
The EXIT keyword has been in Basalt for 10 years. |
Trevor Johnson (329) 1645 posts |
a line ending with ~ (tilde) will be joined to the next lineNow this I like. Yes, this looks like just one useful improvement. |
Rick Murray (539) 13840 posts |
Just one? Ouch! |
Rick Murray (539) 13840 posts |
A geek reading a manual? That’s heresy! ;-)
There’s no other word – FAIL ME, and a dose of facepalm for good measure. |
Steve Drain (222) 1620 posts |
It is strange that the continuation character should catch the attention. I only did it so that I could see lists of structure variables more easily. That took a few minutes; the structures took ages to get right. Be aware that it is not the same as the BB4W continuation with ‘\’. The lines are joined during translation and even though spaces and REMs are removed the total line is still limited to 251 tokenised characters. |
nemo (145) 2546 posts |
I did multiline definitions: class={x,y%,z$ more%,even_more$ bytes%15 LOCALsingleton% .private$ LOCAL.private_singleton DEF.PROCmethod(x):.x=x:ENDPROC } etc. Pity about the DEF.PROC but there would have been too much of a performance hit without it. |
Dave Higton (1515) 3525 posts |
Is there any reason why it could not be backslash, so as to be consistent with BB4W? |
nemo (145) 2546 posts |
And C. |
Steve Drain (222) 1620 posts |
First, there are many existing differences between BBC BASIC in RISC OS and Windows and the way Basalt works makes any attempt to emulate BB4W extensions fruitless. I think of them as similar languages, not the same. However, the choice of continuation character in Basalt is more-or-less arbitrary; it just has to be one that could not ordinarily occur at the end of a line 1. In BBW4 it is slightly different because it has a function within the interpreter and is much more sophisticated, so I imagine Richard chose backslash because it is the last remaining ‘free’ character. In RISC OS BASIC backslash shares the use of introducing a comment in the assembler with semi-colon, so in Basalt I can treat it as ‘free’ by telling users not to use it this way. Having done this I want to use it for structure values, as you see above. Using it for continuation as well might be confusing, and it would add a small overhead to the translation phase, in determining what use was intended. The tilde character has the advantage that its use is quite rare in programs so it presents less of an overhead. Other languages use a variety of continuation characters; I have found _ – & as well \ in the list nemo gave. 1 You could contrive ‘PRINT ~’ with nothing following, but PRINT is a source of all sorts of obscure syntactical problems already and one more like that can probably be accepted. ;-) |
Rick Murray (539) 13840 posts |
The danger here is the issue of existing code, which may use ‘\’ as assembler comments. Oh, and something for people to consider before requesting for Basalt to ape BBFW is that the two are actually syntactically different in how lines are continued – to quote from the online BBFW guide: Note that the continuation lines themselves must begin with another \ character. |
Steve Drain (222) 1620 posts |
No existing code can be affected by Basalt. A programmer must decide to use Basalt and then it is their responsibility to ensure that those limited restrictions it imposes are complied with. Simples. |
Rick Murray (539) 13840 posts |
Fair enough… But no, not “Simples”. Never Simples. :-) |
nemo (145) 2546 posts |
The assembler is not a problem, its a separate parser. Just disallow line continuation in the assembler. |
Steve Drain (222) 1620 posts |
Easy for you to say. Truth be told, Basalt is written not to translate within the assembler, but I have not tested it extensively and it is not documented. |
Pages: 1 2