[plt-scheme] Why do layman programmers care about Currying?

John Clements clements at brinckerhoff.org
Wed Jan 7 00:47:02 EST 2009


On Jan 6, 2009, at 6:36 PM, Grant Rettke wrote:

> On Tue, Jan 6, 2009 at 5:18 PM, John Clements <clements at brinckerhoff.org 
> > wrote:
>> Yes, that's gross.  On the other hand, I find that when writing  
>> Scheme these
>> days, using mutation gives me the willies; it seems less error- 
>> prone to use
>> a state monad, where I don't have to worry about other bits of the
>> computation coming in and messing up the state.
>
> Please elaborate on how you use the state monad in Scheme.

Here's one example; for a compilers class that I'm teaching, I've  
written a toy compiler. The standard way of translating expression  
trees into linear code causes a problem, though; you want to know, for  
instance, what the last basic block was labeled.  One natural way to  
do this is to mutate a variable that stores the label of the most  
recent basic block. (There are certainly other ways to do this.) When  
trying this style, though, I felt more comfortable using a state monad  
to hook things up, rather than using actual mutation.

... or were you just asking how to write code in scheme that uses the  
state monad?

John Clements

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2484 bytes
Desc: not available
Url : http://list.cs.brown.edu/pipermail/plt-scheme/attachments/20090106/88567bf7/smime.bin


More information about the plt-scheme mailing list