[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: printNl question

From: Duke Normandin
Subject: Re: printNl question
Date: Tue, 20 Apr 2021 12:37:26 -0600

On Tue, 20 Apr 2021 10:59:16 -0400
bill-auger <> 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?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]