RE: printNl question

Mark Bratcher <[email protected]> Tue, 20 Apr 2021 16:59:43 -0400
Newsgroups gmane.comp.lang.smalltalk.gnu.general
Message-ID <[email protected]>
Unlike the REPL, when GNU Smalltalk statements are written in a file, even if statements are on separate lines you need the period. Between them.

Sent from Mail for Windows 10

From: Duke Normandin
Sent: Tuesday, April 20, 2021 2:38 PM
To: help-smalltalk
Subject: Re: printNl question

On Tue, 20 Apr 2021 10:59:16 -0400

bill-auger <[email protected]> wrote:

> the period/full-stop is not a required terminator, as in the C

> language - it is separator, between message chains - that is: it

> is not required after the final LOC

Here's the code that I'm using to start learning gnu-smalltalk:

" calculate everage value "

" language: SmallTalk "

| i term sum n |

i := 1.0 .

sum := 0.0 .

n := 0.0

' How many integers are we averaging? ' display.

n := stdin nextLine asInteger.

n timesRepeat: [

' Enter an integer (#' display.

i display.

') > ' display.

term := stdin nextLine asNumber.

i := i + 1.

sum := sum + term

]

' Average = ' display

(sum / n) displayNl

' That is all folks! ' displayNl

I now understand that the period/full-stop is a "statement separator" and NOT a "line terminator".

However, it seems that even though 2 or more statements occur on separate lines, they are treated as occurring on the same line and need a "period" between them. Is that correct? For example:

The 3 variable initialisation lines choke the interpreter unless they're separated by a "period.

Each line in the block of code needs to be separated with a "period" even though they appear on separate lines.

The 2nd-to-last and 3rd-to-last statements do not appear to need a "period" to separate them! Why is that?

--

Duke