Re: Io chokes on sample code

gatesphere <[email protected]> Sun, 26 Feb 2012 10:26:14 -0500
Newsgroups gmane.comp.lang.io
Message-ID <[email protected]>
Not "always", but whenever you have some statements that you're 
separating by newlines.  When you do that, throw a semicolon in there.

As mentioned on the irc channel yesterday, the Io interpreter translates 
newlines into semicolons when it reads in scripts, but in the REPL you 
have to do that manually.

You'll get a feel for it eventually.  I almost never use semicolons now, 
but I used to sprinkle everything with them.

-->Jake

On 2/26/2012 7:51 AM, Duke Normandin wrote:
>
> On Sun, 26 Feb 2012 02:31:18 -0500
> gatesphere <[email protected] <mailto:gatesphere%40gmail.com>> wrote:
>
> > That code would work perfectly in a script. However, in the
> > REPL, you need to put semicolons between statements sometimes.
> > Within parentheses is one of those times. So, corrected code in
> > the REPL is as follows:
> >
> > Io> Account := Object clone do(
> > ... balance := 0.0;
> > ... deposit := method(v, balance = balance + v);
> > ... withdraw := method(v, balance = balance - v);
> > ... show := method(writeln("Account balance: $", balance))
> > ... )
> >
>
> Thanks, Jake!!
>
> So the "rule-of-thumb" is to *always* use semicolons between
> statements while in the REPL? I'll have to check the docs as
> well ...
>
> --
> Duke
>
>