Quantcast
Channel: stardot.org.uk
Viewing all articles
Browse latest Browse all 5552

programming • Re: BASIC rules for IF THEN ELSE

$
0
0
Yes, DEF acts like ELSE, DATA and REM in that the interpreter's behaviour on encountering it is simply to skip to the beginning of the next line.

This can potentially be used to make a procedure or function definition with multiple DEF entry points and a single ENDPROC, where all code that is on the DEF line is only executed when that specific entry point is called and is otherwise skipped. (Of course you could achieve the same effect with GOTO.)

Don't quote me but I think one reason for this design choice is to be compatible with previous (non-Acorn) BASICs that allowed only single-line (indeed single-expression) function definitions "DEF FNfoo(X)=<expression>", but did skip over those definitions when they were encountered during execution.

Statistics: Posted by joachim — Tue Dec 09, 2025 12:42 pm



Viewing all articles
Browse latest Browse all 5552

Trending Articles