BBC BASIC for Windows
Programming >> BBC BASIC language >> BASIC Keywords Syntax http://bb4w.conforums.com/index.cgi?board=language&action=display&num=1226607014 BASIC Keywords Syntax
Post by mohsen on Nov 13th, 2008, 7:10pm
Many keword syntax in the manual indicate that brackets are required (i.e. not optional), e.g.:
This does not seem correct, please correct me if I am wrong.
thanks Re: BASIC Keywords Syntax
Post by admin on Nov 13th, 2008, 10:04pm
Quote:
Many keword syntax in the manual indicate that brackets are required (i.e. not optional)
As it states in the documentation, the syntax descriptions are only informal:
"We have attempted to use descriptions which, whilst being reasonably precise, are readable by the majority of users. To those who would have preferred 'the real thing' - we apologise."
The inclusion of brackets in a syntax description does not necessarily mean they are mandatory, but simply that they are recommended for clarity.
Richard.
Re: BASIC Keywords Syntax
Post by mohsen on Nov 14th, 2008, 12:15pm
"We have attempted to use descriptions which, whilst being reasonably precise, are readable by the majority of users. To those who would have preferred 'the real thing' - we apologise." Richard.
The inclusion of brackets in a syntax description does not necessarily mean they are mandatory, but simply that they are recommended for clarity. Richard.
Using the 2 above statements do we also take it that other brackets are only recommended? e.g. are brackets in MID$( , RND(), etc. only recommended/non-mandatory ?
Re: BASIC Keywords Syntax
Post by mohsen on Nov 14th, 2008, 12:18pm
Another question:
When will the user know for a particular Syntax that brackets are optional (only recommended) and not mandatory?
Can't find in the manual any assistance on that.
Re: BASIC Keywords Syntax
Post by admin on Nov 14th, 2008, 3:07pm
Quote:
do we also take it that other brackets are only recommended?
No, in several cases brackets are mandatory.
Quote:
When will the user know for a particular Syntax that brackets are optional (only recommended) and not mandatory?
Only by trying it. As far as I know a formal (e.g. BNF-style) syntax description for BBC BASIC has never been produced, in the entire 27 years or so the language has existed! That is quite normal for an interpreter.
I can't even guarantee that different implementations of BBC BASIC (6502, ARM, Z80, Windows, Brandy etc.) all adhere precisely to the same syntax.
If in doubt, include the brackets. Only when you are concerned to achieve the fastest possible speed and/or the shortest possible code is it worth the risk and lack of clarity involved in omitting them. Re: BASIC Keywords Syntax
Post by mohsen on Nov 14th, 2008, 4:42pm
The only situations, I could locate for BB4W, where brackets are necessary are:
1. following the Keyword RND (except for RND without an expression), 2. following a calculated GOTO or GOSUB line number, or 3. following a built-in function (such as ABS, ATN, etc.) if the expression following the function is not simple (i.e. an expression containing other operators with the same or lower priorities).
Are there any other situations (possibly new or specific to BB4W keywords or in the built-in assembler) where brackets are mandatory?
I do not think that a reference manual would suggest just "trying it". If it is left for trying, then you wouldn't need the reference manual.
Re: BASIC Keywords Syntax
Post by admin on Nov 14th, 2008, 5:37pm
Quote:
If it is left for trying, then you wouldn't need the reference manual.
It is only necessary for the manual to tell you one way that works; it is unreasonable to expect it to tell you every alternative way. So, telling you always to include the brackets, which is what the BB4W manual does, is in my opinion perfectly sufficient and satisfactory - if you do that the program will always work.
Providing detail of what alternative syntaxes are available (for example when it is permissible to omit the brackets) is the job of a formal syntax description, but as I said one doesn't exist for BBC BASIC.
Quote:
Are there any other situations (possibly new or specific to BB4W keywords or in the built-in assembler) where brackets are mandatory?
Why do you want to know? To answer that question accurately would require me to pore through the source code of the interpreter (about 1 Megabyte), which I'm not inclined to do. Unless you're writing a syntax checker, I don't understand why you need the information.