I am reading the fine tutorial...
For the continue statement we have "Like in many other programming languages, a continue statement starts the next iteration immediately:"
I do not really understand it: If readline() returns an empty string, that empty string is assigned to x. In the next line continue starts the while loop again, but assigning a new value to x is forbidden by intent of the let statement. I have already consulted the manual, but it does not help. My guess: let x is allowed repeatedly while x is the empty string? Really only a guess. And finally: That while loop should never end as written here. I would expect a break statement.
Maybe another way to think of it is that the lifetime of x exists only until the end of each while iteration? What let prevents are reassignments after itself in the same or children scopes. Though you can re-let in nested scopes, which is kinda fun and intended by the language:
block:
let x = 1
echo x
block:
let x = 'c'
echo x
block:
let x = "madness"
echo x
You are right about the break statement iff the intent of the programmer was to break the loop on an empty line. But the purpose of that program is clearly to duplicate non empty lines infinitely for fun. Sort of a meta-turing-machine test.The scope/lifetime of a let statement is until the end of the block it occurs in. When the loop iterates, x isn't visible/bound anymore. It's similar to how F# simplified OCaml's let expression to cut down on excessive nesting.
A hypothetical, OCaml-like syntax for Nimrod's let that makes scoping clearer would be:
while true:
let x = readLine(stdin) in:
if x == "": continue
echo(x)
Also, yes, this is an infinite loop. Presumably that should read while not endOfFile(stdin) instead.