|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
mysterious behaviourI tried the example "Create a simple object and show how to use it" from the page http://www.iolanguage.com/about/samplecode/:
Account := Object clone do( balance := 0 deposit := method(v, balance = balance + v) withdraw := method(v, balance = balance - v) show := method(writeln("Account balance: ", balance)) ) myAccount := Account clone myAccount show "Depositing $10\n" print myAccount deposit(10) myAccount show If I try to deposit I get: Io> myAccount deposit(100) Exception: Account does not respond to 'deposit' --------- Account deposit Command Line 1 And if I try show, I get : Io> myAccount show Exception: Account does not respond to 'show' --------- Account show Command Line 1 And if I try to access the deposit slot I get an endless loop and have to break the Io interpreter by CTRL+D. Where is my error? Thanks BB There are some erors in the example on the page http://wiki.type-z.org/index.php/Io/IoLanguage as wel, as the necessary sign sign := is used = alone - that does not work! Easy to find, but not for beginners with Io, HelloObject = Object clone HelloObject sayHello = method( "Hello World!" print ) HelloObject sayHello() Does anybody know the admin of the page? |
|
|
Re: mysterious behaviour--- In iolanguage@..., "bblochl2" <bblochl2@...> wrote:
> > I tried the example "Create a simple object and show how to use it" from the page http://www.iolanguage.com/about/samplecode/: > > > Account := Object clone do( > balance := 0 > deposit := method(v, balance = balance + v) > withdraw := method(v, balance = balance - v) > show := method(writeln("Account balance: ", balance)) > ) > > myAccount := Account clone > myAccount show > "Depositing $10\n" print > myAccount deposit(10) > myAccount show > > If I try to deposit I get: > > Io> myAccount deposit(100) > > Exception: Account does not respond to 'deposit' > --------- > Account deposit Command Line 1 > > And if I try show, I get : > > Io> myAccount show > > Exception: Account does not respond to 'show' > --------- > Account show Command Line 1 > > And if I try to access the deposit slot I get an endless loop and have to break the Io interpreter by CTRL+D. > > Where is my error? > > Thanks BB > > There are some erors in the example on the page http://wiki.type-z.org/index.php/Io/IoLanguage as wel, as the necessary sign sign := is used = alone - that does not work! Easy to find, but not for beginners with Io, > > HelloObject = Object clone > HelloObject sayHello = method( > "Hello World!" print > ) > HelloObject sayHello() > > Does anybody know the admin of the page? > I just tried the above Account example as a script with a starting shebang line on Linux - it was working! First I tried it from the Io line interpreter with the described results. I tried some other programs in the meantime as well. Just if I use that d() construct for declaration of prototypes with more than one line I get such infinite loop troubles with high frequency accesses to the harddisk with a work overload and short time (seconds) interruption of any other running programs. A prototype with just one line atrribute or method will work ok. May be there is something wrong with the Io line interpreter with the Linux version? A separator problem? May be the line break encoding problem for different OSes? Regards BB |
|
|
Re: Re: mysterious behaviourOn Mon, Jul 13, 2009 at 14:32, bblochl2<bblochl2@...> wrote:
> May be there is something wrong with the Io line interpreter with the Linux > version? A separator problem? May be the line break encoding problem for > different OSes? I haven't had time to try things out but have you tried using one line with ;'s on the REPL? I think the interactive REPL is a little broken on some inputs. Brian. |
|
|
Re: mysterious behaviour--- In iolanguage@..., "bblochl2" <bblochl2@...> wrote:
> > > I just tried the above Account example as a script with a starting shebang line on Linux - it was working! First I tried it from the Io line interpreter with the described results. I tried some other programs in the meantime as well. Just if I use that d() construct for declaration of prototypes with more than one line I get such infinite loop troubles with high frequency accesses to the harddisk with a work overload and short time (seconds) interruption of any other running programs. A prototype with just one line atrribute or method will work ok. > > May be there is something wrong with the Io line interpreter with the Linux version? A separator problem? May be the line break encoding problem for different OSes? > > Regards BB > Playing with the CLI I found that Z_CLI.io does not handle correctly that case and the "slash at the end" case, at lease in my box (Debian Squeze/Sid on amd64). Touching a pair of lines solved the problem for me. I have setup a github repo so so an expert can examine: http://github.com/omf/io/tree/cli Regards |
| Free embeddable forum powered by Nabble | Forum Help |