[fpc-pascal] basic question on begin, end;
Tomas Hajny
XHajT03 at hajny.biz
Wed Sep 23 16:45:12 CEST 2020
On 2020-09-22 14:46, dano none via fpc-pascal wrote:
Hello,
> I have a basic shuffle routine. I put being, end statements in the
> outer loop for clarification.
> It ended up producing random results.
> Commenting out the begin, end combination allows the code to run as
> expected.
> My code is below, can someone tell me if the begin, end combination
> should actually make a difference, or should they be more ornamental
> in function?
.
.
Well, your question suggests that your understanding of the Pascal
language (and creating algorithms in general) shall be improved. The
begin / end pair creates a block which then becomes part of the program
structure. If there is a language construct (e.g. a condition, a loop or
with) which is applied to a statement within the source following this
construct, using begin / end causes the construct to apply to the whole
block between begin / end rather than a single statement, thus it indeed
makes a big difference in many (most) cases.
Tomas
More information about the fpc-pascal
mailing list