BBC BASIC for Windows
Programming >> BBC BASIC language >> Posibility of stict variable types in BB4W? http://bb4w.conforums.com/index.cgi?board=language&action=display&num=1257254937 Posibility of stict variable types in BB4W?
Post by Michael Hutton on Nov 3rd, 2009, 12:28pm
I was just thinking about the possibility of introducing a new mode eg a *FLOAT mode which would guarantee variables are only interpreted as either integers, FLOAT 40's or FLOAT 64's.
So, & - bytes or char %- signed 32-bit integers f - 32 bit floats - 40 bit floats # - 64 bit floats
You would not be able to use integers in 40 or 64 bit floats. Would this be difficult to implement? What would the backward compatibility problems be? Would this be faster? And, would this lead to a true compiler for BB4W?
I would be interested in other peoples thoughts.
Michael Re: Posibility of stict variable types in BB4W?
Post by admin on Nov 3rd, 2009, 3:28pm
Quote:
You would not be able to use integers in 40 or 64 bit floats. Would this be difficult to implement?
Why would you want to take such an apparently retrograde step? The trend in BASICs has for a long time been away from strongly-typed numeric variables towards variant numerics.
For example most BASICs of the 1980s used strongly-typed numerics, like the original BBC BASIC and QBASIC/QuickBasic. At the other extreme, ANSI BASIC and Liberty Basic both have only variant numerics. BB4W lies somewhere in between, with both explicit integer variables and variants.
My BBC BASIC (Z80) was probably one of the earliest BASICs to support variant numerics (integer/40-bit float) and BB4W has extended this to provide integer/40f/64f variants.
So it seems strange to me that you should want to turn the clock back. What you are asking for (floating point variables which cannot contain integers) is exactly what you get in Acorn versions of BBC BASIC and Brandy!!
Quote:
What would the backward compatibility problems be?
Adding extra variable types wouldn't necessarily introduce significant incompatibilities, but there aren't any suitable remaining sigil characters, so how would you represent them?
Quote:
Would this be faster? And, would this lead to a true compiler for BB4W?
If implemented by means of a new *FLOAT mode (as you seemed to suggest) it would of course be slower, not faster, because (being an interpreter) BB4W would have to test the current mode whenever it needed to do something different depending on whether the variable was a variant or a 'strict' float. The number of places where such a test would need to be added is large!
It has no specific bearing on compiling BBC BASIC as far as I can see; why should it?