« Return to Thread: Io N00B - basic questions

Re: Io N00B - basic questions

by spir :: Rate this Message:

Reply to Author | View in Thread

Le Tue, 21 Apr 2009 10:47:12 -0700,
HowardP <how2paut@...> s'exprima ainsi:

> Thanks Jeremy - yes this is helpful.
>
> > Consider:
> > foo ::= 42
> > Creates a slot called "foo" with the value 42, and creates a "setFoo"
> which takes a single argument, the value to update the "foo" slot with.
>
> Then is a 'setWhatever' like a property encapsulation?  In other words, if I
> use the " *::= *" operator/message, I *must* then use it for subsequent
> access to the 'foo' (or 'Whatever') slot?  Or is " ::= " just allowing
> access to more of what goes on under the hood, that is " *:= " hides* the
> setWhatever, whereas "::=" bubbles it up so to speak?
>
> If I'm not totally off here, does that then mean then I'd have to use
>
> setFoo := 99   to get foo to be 99 - and that
>
> foo:=99  would be something else / or raise an exception?
>
> ( I'll test this of course, but thought it would be good to post the info
> anyway, as several of my programming pals are also fuzzy on this too. )

Io> x := Object clone
==>  Object_0x9d7df60:

Io> x a ::= 1
==> 1
Io> x
==>  Object_0x9d7df60:
  a                = 1
  setA             = method(...)

Io> x setA(2)
==>  Object_0x9d7df60:
  a                = 2
  setA             = method(...)

Io> x a = 3
==> 3
Io> x
==>  Object_0x9d7df60:
  a                = 3
  setA             = method(...)

Io> x a := 4
==> 4
Io> x
==>  Object_0x9d7df60:
  a                = 4
  setA             = method(...)


While I wouldn't guess about the intention of Io developpers, I personly consider '::=' as a nicety that also sets a setter.
set* does not build a kind of property. Note:

Io> x m ::= method("m running")
==> m running
Io> x
==>  Object_0x9d7df60:
  a                = 4
  m                = method(...)
  setA             = method(...)
  setM             = method(...)


Denis
------
la vita e estrany

 « Return to Thread: Io N00B - basic questions