Author |
Topic: BASIC Keywords Syntax (Read 1009 times) |
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: BASIC Keywords Syntax
« Reply #4 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.
|
|
Logged
|
|
|
|
mohsen
New Member
member is offline


Gender: 
Posts: 39
|
 |
Re: BASIC Keywords Syntax
« Reply #5 on: Nov 14th, 2008, 4:42pm » |
|
on Nov 14th, 2008, 3:07pm, Richard Russell wrote:No, in several cases brackets are mandatory. |
|
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?
In all other cases brackets are not required.
on Nov 14th, 2008, 3:07pm, Richard Russell wrote:
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.
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: BASIC Keywords Syntax
« Reply #6 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.
Richard.
|
|
Logged
|
|
|
|
|