Author |
Topic: BASIC Keywords Syntax (Read 1007 times) |
|
mohsen
New Member
member is offline


Gender: 
Posts: 39
|
 |
BASIC Keywords Syntax
« Thread started on: Nov 13th, 2008, 7:10pm » |
|
Many keword syntax in the manual indicate that brackets are required (i.e. not optional), e.g.:
<n-var> = OPENIN ( <string> ) <n-var> = OPENOUT ( <string> ) <n-var> = OPENUP ( <string> ) <n-var> = ABS ( <numeric> )
etc....
This does not seem correct, please correct me if I am wrong.
thanks
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


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


Gender: 
Posts: 39
|
 |
Re: BASIC Keywords Syntax
« Reply #2 on: Nov 14th, 2008, 12:15pm » |
|
on Nov 13th, 2008, 10:04pm, Richard Russell wrote:"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. |
|
on Nov 13th, 2008, 10:04pm, Richard Russell wrote: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 ?
|
|
Logged
|
|
|
|
mohsen
New Member
member is offline


Gender: 
Posts: 39
|
 |
Re: BASIC Keywords Syntax
« Reply #3 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.
|
|
Logged
|
|
|
|
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
|
|
|
|
|