There might be different uses i.e.: applications (fullscreen & GUI), compiled and interpreted, "applets" (plugins in webbrowsers), SSI like Perl/PHP/Python, an alternative to ECMA-Script and macro scripting e.g. in office suites and for desktop automation, resp. overall any application scripting. But all should use in principle the same syntax - although you might not copy your code in a webserver script and it will draw a website...
Therefore should be only a rather limited set of instructions comparable to C, which only consists of "keywords" instead of "instructions" and "loads" most of its functionality from libraries.
The BASIC standard should be rather similar to natural spoken English, as if you are telling the computer in words what it should do. And it should be still be based upon the original or traditional BASIC if it makes sense.
LOAD
Because of this, I'd use LOAD instead of #include. You may still use preprocessor directives for a BASIC compiler, but this should be deprecated. The code shouldn't be platform dependent and only use BASIC instructions. You may of course still link DirectX libraries. But in principle there should be no need for a #ifdef __WIN32__ or similar; this should be used in external C/ASM coded libraries/object files. Same applies to Inline-Assembler.
The LOAD instruction merges other BASIC source codes or links libraries/object files depending on file extensions. Maybe ".BAS" is for BASIC listings, ".BI" might be supported too. Real libraries have no extension. To make a C analogous example: "LOAD "stdio"" will add the prototypes e.g. of "printf()" to the namespace, and the linker(compiler collection) will know to link the "stdio.lib" resp. "stdio.dll", "stdio.a" and so on... The compiler settings are demanding which version of library - among other things debug or release - and if to link statically or dynamically. So the programmer has only to write "LOAD" and the library will work with the first test run.
Datatypes and declarations
"DIM AS <type>" is very tradition-conscious BASIC. But I'd keep still the suffixes. To be precisely: $ for strings, % for integers, ! for booleans, § for decimal variables and ? for a maybe-variant-type. This spares typedefs and is more obvious. - It will also mean that e.g. MID$() is the function and MID the instruction... If you use a new variable without suffix, it is expected to be of the type "real", which means normally double, but might be also "float" on feeble hardware or "long double". "Integer" is signed 32 bit but may vary too, <variable>.size or SIZEOF(<variable>) will reveal the current range resp. accuracy. "mystring$ AS INTEGER" will cause a syntax error - even "i% AS UINT16".
Variables and subroutines shouldn't have to be declared before you use them. Therefore a compiler/interpreter has to collect prototypes and typedefs first and parse a sourcecodefile then in a second run-through. All subroutines(functions) are distinguished by parameter lists and return values, although this only means boolean, strings, buffers/pointers and normal numeric values. Further "BYVAL" is default, only BYREF has to be stated.
Loops
I think "REPEAT" is better than "DO". REPEAT, WHILE, LOOP and UNTIL may be combined as you want. REPEAT can also have the argument "<n> TIMES" which repeats the loop content n times. In machine code this means a faster loop counting to 0, e.g. "8 TIMES" from 7 to 0. Maybe you might also access the counter. - "<variable> AS INDEX" ?
Instead of "EXIT" I'd use "LEAVE". "GOTO" should exist still too, although I believe EXIT/LEAVE makes it superflues.
The NEXT of FOR-NEXT may show/allow the counting variable, added by the editor, but not required. I'd further add FOR EACH from PHP:
Code: Select all
FOR EACH a$ = name$() i% AS INDEX
b$=MID$(a$,...)
b$=MID$(name$(i%),...)
NEXT a$