[plt-scheme] mutation in typed scheme structs

From: David Van Horn (dvanhorn at ccs.neu.edu)
Date: Tue Apr 13 11:13:11 EDT 2010

On 4/13/10 11:10 AM, keydana at gmx.de wrote:
> Hi,
>
> one question regarding typed scheme: can I use mutation in typed scheme structs, like e.g.
>
> (define-struct: pt ([x : Real] [y : Real]))
> (define p (make-pt 1 2))
> (set-pt-x! p 22)
>
> I tried adding #:mutable to one of the fields with different syntaxes, but didn't get it to work - could someone give me a little hint please?

I believe you can only specify structure-level (not field-level) 
mutability in Typed Scheme:

#lang typed/scheme
(define-struct: pt ([x : Real] [y : Real]) #:mutable)
(define p (make-pt 1 2))
(set-pt-x! p 22)

David


Posted on the users mailing list.