[Tutor] running a script from IDLE

Scott Widney SWidney@ci.las-vegas.nv.us
Mon, 11 Mar 2002 13:54:40 -0800


> >Correct and FP is quite happy for you to return a new reference
> >to the modified pencil. The point of returning values is that
> >you can apply value substitution to prove the correctness of
> >the solution. (The real FP afficianados wuill be screaming
> >at me real soon :-) When a function performs its task without
> >returning a value you lose the concept of the entire program
> >being an expression that is evaluated.
> 
> ...which is how I'm contrasting object.method() calls which
> change object state without returning anything.  The point
> of the method is to change the internal state of the object.
> Nothing is returned.

Hmmm... in Alan's example above, you could always have the function return a
boolean indicating its success or failure at performing the task. One level
up you'd have logic that would react accordingly. Now it's back to being
functional again....

Actually, Kirby's object.method() ought to do that as well. Perhaps you've
asked the method to change the object in a way that was never intended. You
could have safeguards within the methods, but reporting an error would
become a side effect. So, instead, in essence you're asking the object to
modify itself, and it's responding with either "OK, done" or "I'm sorry,
Dave, but I can't do that."

Oversimplified perhaps, but it seems as though having functions and/or
objects only report errors, while leaving it to the caller to react to the
error makes both more functional.

Scott