On Wed, 08 Mar 2006 17:05:45 +0100, suchodj@wanadoo.fr wrote:
>Hello Bryan
>in your answer to my question you wrote
>
>"The result of a puts statement is the empty string, and that is what
>you see in the text widget. What you see in the console is the effect
>of the puts command, not the result of the puts command. Those are
>two different things."
>
>I understood that " The result of a puts statement is the empty
>string, and that is what you see in the text widget "
>
>However i did not pay enough attention to the rest of the your text:
> " What you see in the console is the effect of the puts command,
>not the result of the puts command. Those are two different things."
>
>i tried hard to understand the difference in this case of
>
>is the effect
>not the result
>
>could you please explain to me the difference because
>i failed to understand.
>looking forward to read you
>Thank you in advance
Hi jerome,
maybe you know the term 'side effect of a function'? Let's take some
examples:
A classical function like 'y = sin(x)' (C syntax) just returns a value
and has _no_ side effects - you'd be much surprised if it did more
than just return a value.
Now let's consider [open ...]: It returns a file handle / file
descriptor as a result (we ignore errors here), but there were
potentially lots of side effects:
- The OS might have turned to a network server to have your file
opened there.
- The OS might have needed to look up the file, maybe seek to the end
(append mode) or truncate an existing file.
- ...
How about your super-mega function 'makeUserMillionaire' which gets
activated by clicking on the appropriate button. It does lots of
magical stuff and - if all works well - turns the user into a
millionaire. _That_ is the side effect - the _result_ is merely 1 or 0
indicating success or failure.
HTH
Helmut Giese
Received on Sun Apr 30 02:27:51 2006