18,700
edits
(explaining declaration and type spec; mentions of other sections are now links to them) |
(→Compound statements: explanation of "scope") |
||
Line 41: | Line 41: | ||
{dmsg("Statement 1"); dmsg("Statement 2"); dmsg("Statement 3");} | {dmsg("Statement 1"); dmsg("Statement 2"); dmsg("Statement 3");} | ||
The purpose of doing this is to group some statements under a header, which can be either a function declaration (see [[#Declaration|Declaration) or an "if" statement (see [[#Conditional|Conditional]]). | The purpose of doing this is to group some statements under a header, which can be either a function declaration (see [[#Declaration|Declaration) or an "if" statement (see [[#Conditional|Conditional]]). Such a group of statements is referred to as a block, and is also said to be in a scope. Traditionally in programming, anything inside a certain level of shared braces can be seen from elsewhere within those braces, or from within a scope inside that scope, but not from a scope outside that scope. This allows careful management of which code can alter which data. In BSL's case, there are certain issues with scope not being respected (see the section on the [[#if|if]] statement). Variables outside of all scopes (such as functions) are referred to as "globals". | ||
===Comments=== | ===Comments=== |