RISC OS Open
A fast and easily customised operating system for ARM devices
ROOL
Home | News | Software | Bugs | Bounties | Forum | Documents | Photos | Contact us
Account
Forums → Wish lists →

Extending BBC Basic...

Subscribe to Extending BBC Basic... 20 posts, 9 voices

 
Jun 5, 2007 11:24am
Avatar Alex Farlie (144) 35 posts

Hi.

In other versions of BBC Basic, notably the Windows version by RT Russell some improvements have been made. It is STRONGLY suggested that someone from Castle or RISC OS Open liaise with them so that some of the BB4W improvements could at the very least be synced back into the ARM version.

In particular I would like to request extension of ARM BBC Basic to allow use of the structure syntax present in the Windows version.

In terms of a more radical extension, how easy would extension of BBC BASIC to cope with ‘Object’ techniques be, given that implementations of simple OO lanaguges (e.g !Squeak) already exist for RISC OS?

 
Jun 5, 2007 6:46pm
Avatar Steve Revill (20) 899 posts

We’re quite happy to see that happen. The sources to BASIC have been released so interested parties (such as Steve Drain and RTR) can get in there and add features.

 
Jun 5, 2007 11:06pm
Avatar Alex Farlie (144) 35 posts

I don’t see commercial developers like RTR jumping into shared source, personally.

However, perhaps ROOL/Castle could try to start a standardisation procedure between some of the disparate versions? (such as Basic V, Brandy , and BB4W)

The aim of such standardisation might be to allow for the creation of a modern BBC Basic (say Basic 8) which had modern features like structures, objects and 3D (noting that Iyonix supports 3D).

Structures would (for Windows style syntax at least) needs someone ‘offical’ to ask RTR extremely nicely for a specification.

However this might not be needed if structures and objects are treated together. Objects are straightforward to implement (assuming knowledge of C/ARM code and how C++ compilers work) but time consuming to write parsers for.

Some of my own thinking in regard to ‘objects’ is as follows :

An object is declared in Basic 8 as follows.
'DIM' 'CLASS' {identifier}'~[TO' {identifier}[,{identifier}]]'
{block}
'END' 'CLASS'

{block} can be any valid BBC Basic code with the exception of the END CLASS statement. An alternative method would be to declare a class by it’s constructor.

Non local variables (i.e. those inside methods) created would have ‘object scope’ and would be created for the object by initialisation, or explicitly via LET.

Assuming a CLASS already existed the DIM statement could be written shorthand as
'DIM' {identifer1}~ 'CLASS' TO {identifer2}~ 

Which would create a class in memory

In memory the location in the variable table for {var}~ would contain a pointer to a variable list and a pointer to a list of procedure/function names, both these pointer would be 32bit with an appropriate

Hence the code sequence:
DIM CLASS point~:
 x%=0  : REM field
 y%=0 :  REM field

 DEF PROCplot
  PLOT 69,x%,y%
 ENDPROC

END CLASS

would create in memory:

point~ entry in variable list Address of 'class' paramatter block.

!(point~)    Link to next object. (note this list need not be contiguous) 
             Value would be dependent on what objects already declared.
(point~!4)   parent or prototype (this is relevant re inheritance) =NUL
(point~!8)   Method number or 0 =1
(point~!12)  link to next method = NIL
(point~!bb)  Address of tokenised code to do procedure/function
(point~!aa)  'p''l''o''t' [NUL] 
              NB additonal NULS would be padded to 
              ensure word alignment.

(point~!zz)  End of methods (FFFF EEEE)
(point~!aa)  Number of variables.
(point~!aa+4) Address of datablock
(point~!aa+8)  Offset to Next entry 
               = 8 ( see point~!bb)
(point~!aa+12) Offsest from !bbb  
               =0
(point~!aa+16) 'x''%'[NUL][NUL]

(point~!bb     Offset to Next entry= NIL
(point~!bb+4)  Offset from !bbb = 4
(point~!bb+8) 'y''%'[NUL][NUL]
{point~!cc+4) end of object.

Feel free to correct me if my understanding of variable layout on BASIC V is mistaken , I can swap fields around if needed.

The use of ~ to refer to a 'class' pointer variable of course assumes ~ as a variable type CAN be distinguished from ~ used as an operator in PRINT statements in Basic 8. Feedback on the above is much appreicated, espically if you (or others actually want to put this syntax in BBC Basic :) )

 
Jun 5, 2007 11:07pm
Avatar Alex Farlie (144) 35 posts

Apologies for the formatting mess… Will send the ASCII version to email if interested :)

 
Jun 6, 2007 3:19pm
Avatar Andrew Hodgkinson (6) 318 posts

Try wrapping what you intended to say in <notextile> and </notextile> tags, and/or, since some of it appears to be fixed layout plain text, <pre>...</pre>.

There’s a tests page in the Wiki which can be handy for playing about with Textile :-)

 
Jun 13, 2007 12:43pm
Avatar nemo (145) 437 posts

The whole OOBASIC thing was thrashed out between the two Steves, Richard and I years ago, and R went on to implement some of it in the Windows version. I did the whole lot including class methods and “templating” (which was actually a form of casting).

Perhaps this would be a good outlet for some of that old stuff.

 
Jun 13, 2007 8:57pm
Avatar Alex Farlie (144) 35 posts

Nemo, Willing to share? :)

If so I think you’ve kickstarted Basic 8 ( 8 looking like two stacked o’s)

Did you have a technical paper you could put on something like the wiki here (or one of the other RISC OS) wiki’s?

What where your thoughts on the ‘object’ layout I suggested BTW?

 
Jun 14, 2007 1:34pm
Avatar nemo (145) 437 posts

Erm, didn’t like the syntax. We all decided on:

class = {x%,y,z$
DEFPROC+ : REM This is the constructor
y=PI
z$="New!" 
ENDPROC
DEFFNmethod(arg$)
=arg$+z$
}
instance = NEW class
instance.x%=12
PRINT instance.FNmethod("Woo")

Do a search on Google Groups for all the torrid details.

 
Jun 15, 2007 2:27pm
Avatar Alex Farlie (144) 35 posts

Your syntax looks better…

You also had some thoughts on how to tweak the interpreter it seems, with the sources now available perhaps you could make some tests, assuming the sources build.

 
Jun 18, 2007 8:35pm
Avatar nemo (145) 437 posts

with the sources now available

I’ve always had a source!

 
Jun 19, 2007 7:13am
Avatar Alan Robertson (52) 127 posts

Nemo, It’s good to see you back (at least temporarily) on the RISC OS scene.

Wish you’d come back. It would be good to have you working on the sources…

Anyway, all the best.

 
Jun 20, 2007 8:02am
Avatar nemo (145) 437 posts

Too kind.

 
Dec 10, 2011 2:26pm
Avatar Trevor Johnson (329) 1468 posts

David Braben has mentioned BBC BASIC on the Raspberry Pi (thanks for pointing it out, Vince) so is it worth picking up the "Basic 8" discussion again?

Also, this morning’s c.s.a.programmer thread on Running BASIC text files talks about renumbering 1,1. If we want to be able to diff BASIC sources here then is this important? (I’ve no idea what the largest BASIC RO source file is.)

 
Dec 11, 2011 4:55pm
Avatar Trevor Johnson (329) 1468 posts

Thanks… and to push it right to the limit, instead of RENUMBER 10,1 we could even use RENUMBER 0,1!

 
Dec 11, 2011 8:18pm
Avatar Sprow (202) 438 posts

could even use RENUMBER 0,1

I thought about that, but I’m aware that some things prefix libraries to other BASIC programs where the library is (effectively) done with RENUMBER 0,0 – ie. every line is line 0 – using some combination of *LOAD and the value of TOP.

I couldn’t think of a situation where your would interleave 9 lines of one program with 1 line of TEXTLOADed program, so for maximum compatibility just changing the step seemed safest. Frankly, if you’ve got 65279 lines of BASIC and those last 9 are important to you, you’re probably using the wrong language.

 
Dec 12, 2011 8:18am
Avatar Trevor Johnson (329) 1468 posts

for maximum compatibility just changing the step seemed safest

Sorry and thanks for the detailed explanation.

 
Dec 14, 2011 9:04pm
Avatar Trevor Johnson (329) 1468 posts

In case I forget to add this to the bug tracker (when it’s available again)… does faulting zero shifts (thanks John Kortink and Martin Wuerthner) mean anything?

 
Dec 15, 2011 2:01pm
Avatar Sprow (202) 438 posts

does faulting zero shifts mean anything?

Well yes, ASR and ROR can’t do shifts of 0 (LSL and its alias ASL can) because the instruction encoding forbids it (ASR is 1 to 32 encoded in 5 bits as 0 to 31, and ROR#0 encodes RRX).
I checked in RealView armasm and it faults ASR#0 and ROR#0 too so I think BASIC probably should too.

Typically, you’ll hit the problem as Martin says when you’re using BASIC to do run time code generation, and I think that’s probably also the time you do want the error since the code generator has output something probably isn’t what was wanted. An alternative is to go via a macro:


MOV r0, r0, ASR#3-log2bpp%

replaced with

OPT FNdoasr(3-log2bpp%)

and to deal with the shift of zero there.

 
Dec 15, 2011 5:49pm
Avatar Andrew Rawnsley (492) 194 posts

Edit: Post was made on wrong thread, sorry.

 
Dec 18, 2011 11:29pm
Avatar James Lampard (51) 119 posts

I thought about that, but I’m aware that some things prefix libraries to other BASIC programs where the library is (effectively) done with RENUMBER 0,0 – ie. every line is line 0 – using some combination of *LOAD and the value of TOP.

I don’t quite understand this, if you want to add a library to a basic program you suffix it onto the end surely? I can’t think of any reason why you would want it to come before.

I couldn’t think of a situation where your would interleave 9 lines of one program with 1 line of TEXTLOADed program, so for maximum compatibility just changing the step seemed safest.

If you had a program which had a library added to it where every line was numbered 0, and you TEXTLOADed it as a text file, interleaving would be the least of your problems. You would only get the last line of the library (which would replace all the earlier ones numbered 0)

Frankly, if you’ve got 65279 lines of BASIC and those last 9 are important to you, you’re probably using the wrong language.

True.
Am I missing something obvious on the earlier issues?

Reply

To post replies, please first log in.

Forums → Wish lists →

Search forums

Social

Follow us on and

Commercial use

For commercial enquiries, please contact the owners of RISC OS, Castle Technology Ltd.

ROOL Store

Buy RISC OS Open merchandise here, including SD cards for Raspberry Pi and more.

Donate! Why?

Help ROOL make things happen – please consider donating!

Description

What would you like to see written or changed?

Voices

  • Alex Farlie (144)
  • Steve Revill (20)
  • Andrew Hodgkinson (6)
  • nemo (145)
  • Alan Robertson (52)
  • Trevor Johnson (329)
  • Sprow (202)
  • Andrew Rawnsley (492)
  • James Lampard (51)

Options

  • Forums
  • Login
Site design © RISC OS Open Limited 2011 except where indicated
The RISC OS Open Beast theme is based on Beast's default layout

Valid XHTML 1.0  |  Valid CSS

Powered by Beast © 2006 Josh Goebel and Rick Olson
This site runs on Rails

Hosted by Arachsys