Le Tue, 21 Apr 2009 16:59:55 -0400,
Jeremy Tregunna <
jeremy.tregunna@...> s'exprima ainsi:
>
> I'm not sure what you're trying to get at Denis. Can you elaborate?
>
> On 21-Apr-09, at 4:33 PM, spir wrote:
>
> > 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.
Here I mean: "::=" creates a setter, but does not force its use: as shown by the example, you can still write '=' or even ':=' for the same slot (name).
> > set* does not build a kind of property.
First, because of the above (property is usually encapsulation).
Note:
> >
> > Io> x m ::= method("m running")
> > ==> m running
> > Io> x
> > ==> Object_0x9d7df60:
> > a = 4
> > m = method(...)
> > setA = method(...)
> > setM = method(...)
Here, '::=' creates a setter for a method slot. Which is indeed just a slot for Io. Properties are usually (AFAIK) meant for controlling access to data instead.
Hem, actually this may be a wrong interpretation of mine. Even when called (as opposed to read or written like any other slot) methods need first be looked up. So that encapsulation through getter/setter may well apply to them like to pure data slots.
Critics welcome ;-)
Denis
>
> Regards,
>
> Jeremy Tregunna
>
jeremy.tregunna@...
------
la vita e estrany