[plt-scheme] Explaining assignment

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Fri Feb 20 15:23:01 EST 2009


On Feb 20, 2009, at 11:01 AM, Marco Morazan wrote:

> Part VII of HtDP introduces the concept of state variables and
> explains set! as having the effect of changing the definitions of
> state variables.

This is the semantics (what do they mean?) of assignment statements.


> It does not explicitly mention, however, that set!
> (or assignment in general) is a means for functions to
> communicate/share values with each other without having to call each
> other to communicate values via arguments for parameters.

This is the pragmatics (why and when are they useful?) of assignment  
statements.

I routinely teach these parts (when I teach them) with just those  
explanations. I believe the communication idea is somewhere in this  
chapter but I will admit that I was afraid of complaints about the  
nature of my English explanations. So I may have tried to water it down.

There is of course another aspect of pragmatics. When some library  
writer chooses to introduce a certain signature for a method/loop you  
often have no choice but to use assignment statements (see GUI  
callbacks in Java or for-loops in "ugly" languages). That's also a  
part of the pragmatics (when I am forced to program with assignment  
statements).

-- Matthias



Posted on the users mailing list.