[Tutor] running a script from IDLE

alan.gauld@bt.com alan.gauld@bt.com
Tue, 12 Mar 2002 17:10:12 -0000


> z-plane. I'm going to call icosa.rotate(z=90) or something 
> similar. Before I tell the View to refresh itself, I want 
> to be sure that the Model has changed. How can I be sure 


The convention for this in Smalltalk is either to return self or to return
the value being set. Thus you get back whatever the attribute value is
*after* the operation. You can compare that to either the previous value of
the new one:

fZ = foo.getZ
if foo.setZ(42) == fZ: # failed

OR

if foo.setZ(47) == 47: # success...

As an aside,
Using a variable demonstrates why pure FP doesn't want you 
changing the incoming parameter:

bar = 52
if foo.setZ(bar) == bar: # only works if setZ didn't mess with bar!

Alan g