Python vs. Io

Josiah Carlson jcarlson at nospam.uci.edu
Fri Jan 30 22:10:07 EST 2004


> I'm not sure how to tell you this so I'll just give a heavily
> commented example (comments in Io are with #, //, or /* */)
> 
> parentProto := Object clone //makes parentProto a new object
> //:= is used for creating new variables
> parentProto shared := 5 //parentProto's new slot shared holds 5
> parentProto different := 6
> parentProto sum := method(shared + different) //self isn't necessary
> write("parentProto's sum: ", parentProto sum, "\n")
> x := parentProto clone //essentially new instance of parentProto
> y := parentProto clone
> x different = 2 //just updating slots is done with =.
> y different = 3
> write("first x sum ", x sum, "\n",
>       "first y sum ", y sum, "\n")
> parentProto shared = 7 //should show up on all clones
> write("later x sum", x sum, "\n",
>       "later y sum", y sum, "\n")
> 
> Does that illustrate it well? I know the difference between := and =
> is annoying, but you'll get used to it, and it allows really cool
> things to be done with scopes and inheretance.
> 
> Daniel Ehrenberg

After looking at your sample code, I couldn't help but say 'ick'.  Maybe 
it is my C and Python background, but just putting a space between an 
object and its properties looks ugly.  The use of method() also makes my 
skin crawl.

It is cool that you dig on Io, and I wish you the best.

  - Josiah



More information about the Python-list mailing list