[plt-scheme] 4.0 question

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sat Dec 15 20:46:14 EST 2007

At Sat, 15 Dec 2007 20:39:57 -0500, Prabhakar Ragde wrote:
> Why are cons cells immutable by default but structures mutable by 
> default? 

Structures are immutable by default:

 Welcome to MzScheme v3.99.0.4 [3m], Copyright (c) 2004-2007 PLT Scheme Inc.
 > (define-struct a (b c))
 > set-a-b!
 reference to undefined identifier: set-a-b!
 > (define-struct a (b c) #:mutable)
 > set-a-b!

> And did you consider making definitions immutable by default, 
> that is, having both (define <var> <exp>) and (mdefine <var> <exp>) 
> forms?

Since mutations to variable are lexically apparent (in a `module'
world), they do not create anywhere near as much trouble.


Posted on the users mailing list.