Re: CASE...ENCASE Query...



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
.



Relevant Pages

  • Re: CASE...ENCASE Query...
    ... We all know that many programmes are full of ... reference to it in the manuals. ... the interpreter, which is doing exatly what you should expect it to do, ... ENDIF structure and a single exit point, ...
    (comp.sys.acorn.programmer)
  • Re: CASE...ENCASE Query...
    ... Why slow the interpreter down. ... *always* better ways of achieving the same result, ... BBC BASIC that don't support EXIT. ... reference to it in the manuals. ...
    (comp.sys.acorn.programmer)
  • Re: CASE...ENCASE Query...
    ... Why slow the interpreter down. ... How does BB4W detect the end of a WHEN clause? ... the manuals that you mustn't do it. ...
    (comp.sys.acorn.programmer)
  • Re: Choice of programming language
    ... Fortran as it is slower. ... CPU instructions than interpreter has. ...
    (sci.math.num-analysis)
  • Re: For performance, write it in OCaml
    ... is shorter. ... Not with the interpreter; it's slower. ... Haven't tested the compiler yet. ...
    (comp.lang.ruby)

Loading