Heater wrote: ↑
Tue Apr 16, 2019 2:42 pm
C, for example, has a lot of platform dependent things. The size of int for example. A language like BASIC should not.
I absolutely agree, in principle. Indeed I would argue that one of BBC BASIC's Unique Selling Points
is the ability to write programs which run without modification on the full range of supported disktop and mobile platforms (Windows, MacOS, Linux, Raspberry Pi, Android, iOS) even if the program is leveraging what would usually be considered platform-specific features such as 3D graphics, audio input and output, network access, shader programming and so on. I doubt that there are many languages around that can offer that degree of cross-platform compatibility.
But it's not perfect, and as you say the size of BBC BASIC's native floating point data type is a case in point (80-bits extended precision on x86 CPUs, 64-bits double precision on ARM CPUs). When I started developing BBC BASIC for SDL 2.0
I didn't realise that the ARM didn't support 80-bits floats. I knew that the original ARM made provision for floating-point extensions (then implemented in software) which did
include that data type, and I knew that Intel's rationale for providing that data type in the FPU was to allow 'chained' floating-point calculations which didn't lose precision even if they involved several steps.
So when I came to compile BBCSDL on ARM I was surprised to discover the absence of 80-bit floats, and had to work around that shortcoming. In practice the resulting incompatibility is small: the default numeric type written-to and read-from data files is still the old 40-bit (32-bit mantissa, 8-bit exponent) format used in the BBC Micro and my early BASICs, so that isn't affected. Suffixless ('variant') variables and arrays still allocate 10-bytes per member, even when compiled on ARM. And 64-bit integers can be stored in variants even when (as on ARM) the mantissa of the native floating-point type isn't big enough. Finally, you can force the use of 64-bit doubles, on all platforms, by adding a hash suffix to the variable name.
But it would have been better if ARM had supported 80-bit floats, and I'm still surprised that they don't, especially when the original Acorn ARM architecture anticipated that they would.