[racket] Class Philosophy and Fields

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Tue Jun 12 22:10:03 EDT 2012

On Jun 12, 2012, at 12:03 PM, Hillary Ryan wrote:

> Hello,
> Disclaimer: I am new to Racket, so please forgive the ignorance. 
> Questions:
> 1)  As a functional language, when Racket implemented classes did it do so with a different perspective or design philosophy than procedural languages that made a similar transition? In other words, what is the correct, Rackety way to think about and to use classes?

The most important difference is that classes are values just like functions and numbers. 

> 2) Reading through the documentation it seems that there are three different ways to update fields:
> How do these approaches differ? And when should I use one over the other?

There are two ways: an imperative one (using set!) and a functional one (using new this%). As long as your performance is acceptable, I'd recommend the second one. 

Posted on the users mailing list.