libfawk's BASIC: fbas

Libfawk BASIC, fbas (for function-BASIC), is a modern, third-generation dialect of the BASIC language. It features control flow (loops) and functions. Inherited from libfawk, it also supports array-in-array, struct-like array addressing syntax, function references saved in variables and the builtin functions and variables of fawk.

Although there is no GOSUB, fbas still has GOTO and optional line numbering (that can be used mixed with line labeling). This allows traditional (1970s/1980s style) basic programming.

Major differences from the common dialects


Why bracketed arrays?

Consider A[1](2). It clearly means A is an array, A[1] is a member of the array referencing a function and (2) is the call parameter. If it was A(1)(2), it could also be interpreted as an array-in-array situation (equivalent to A[1][2] in the current syntax).

Why no gosub?

Soft reason: size vs. features. Gosub does not make it possible to pass function parameters while the alternative syntax with def/function does. To keep the code small, only one syntax is implemented for the same feature, which is def/function in this case.

Hard reason: the libfawk VM and the host application expects to call a function called main() within the script. With BASIC this is not the case since the main program just starts outside of functions. To make this possible, there is a trick in the compiler - a trick that needs to know the start of each function, which is not possible with subroutines defined for gosub.