Re: CASE...ENCASE Query...
- From: malshayef@xxxxxxxxx
- Date: Sat, 10 Jan 2009 04:52:38 -0800 (PST)
On Jan 10, 2:09 pm, Richard Russell <n...@xxxxxxxxxxxxxxx> wrote:
On Jan 8, 4:00 pm, malsha...@xxxxxxxxx wrote:
It does not make sense to check for and mandate an expression after
WHEN or OTHERWISE. Why slow the interpreter down.
Ah, but allowing WHEN other than at the start of a line probably does
slow the interpreter down! In BBC BASIC for Windows the 'jump' to the
ENDCASE is very fast because it knows that the WHEN (or OTHERWISE)
must be at the beginning of a line; therefore it can easily skip to
the next line using the 'line length' byte to tell it how far to
advance. If it had to accept WHEN elsewhere on a line, it would
probably use a much slower 'search for the next CR' method of locating
the end of the current line.
Would you say that because the below usage of NEXT is undocumented
it should not be used.
10 : FOR I%=0 TO 9
20 : IF I%<5 NEXT
30 : PRINT I%
40 : NEXT
50 : PRINT "DONE"
I would say it should not be used, yes. For a start it will break
automatic indentation in editors that support it. Secondly, there are
*always* better ways of achieving the same result, even in versions of
BBC BASIC that don't support EXIT.
But, as far as I know, you can't find
reference to it in the manuals.
There is nevertheless a big difference from the WHEN situation. The
manuals *do* explicitly state that WHEN and OTHERWISE must be the
first item on a line (after the line number). Therefore in using WHEN
in the non-standard way you propose you are not only relying on
undocumented behaviour, but acting contrary to a clear statement in
the manuals that you mustn't do it. There is no similar warning in
the manuals about the placement of NEXT.
Richard.http://www.rtrussell.co.uk/
To reply by email change 'news' to my forename.
Remember Richard that we are talking about ARM BBC BASIC interpreter
which I believe (in general) is a little slower than BB4W (all
things being equal).
Mohsen
.
- Follow-Ups:
- Re: CASE...ENCASE Query...
- From: Richard Russell
- Re: CASE...ENCASE Query...
- References:
- CASE...ENCASE Query...
- From: usenet
- Re: CASE...ENCASE Query...
- From: Derek Haslam
- Re: CASE...ENCASE Query...
- From: usenet
- Re: CASE...ENCASE Query...
- From: malshayef
- Re: CASE...ENCASE Query...
- From: Richard Russell
- CASE...ENCASE Query...
- Prev by Date: Re: CASE...ENCASE Query...
- Next by Date: Re: CASE...ENCASE Query...
- Previous by thread: Re: CASE...ENCASE Query...
- Next by thread: Re: CASE...ENCASE Query...
- Index(es):
Relevant Pages
|
Loading