<br><div class="gmail_quote">On Sat, Feb 7, 2009 at 10:06 AM, Matthias Felleisen <span dir="ltr"><<a href="mailto:matthias@ccs.neu.edu">matthias@ccs.neu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d"><br><br></div>Think of the World as an object for which you have three or four methods:<br>
<br>
;; tick : World -> World<br>
;; click : World KeyEvent -> World<br>
;; clack : World MouseEvent - World<br>
;; draw : World -> Scene<br>
;; stop? : World -> Boolean<br>
<br>
As you can see (1) these methods belong together, (2) in a functional language you must pass in the world, and (3) you usually destructure it via field access to the struct. So there is clearly a certain intellectual elegance to<br>
<br>
(define World<br>
(class ...<br>
;; -> World<br>
(define/public (tick) ...)<br>
;; KeyEvent -> World<br>
(define/public (click ke) ...)<br>
;; MouseEvent -> World<br>
... ))<br>
<br>
Pardon my Java :-) You see it's really about having classes around to organize your code. It has nothing to do with Java.<br>
<br>
Better still, you can use inheritance to prepare default behaviors and then quickly instantiate this anticipated scenarios. When I teach Softw Dev (~12 Kloc to 18 Kloc of Java for the poor students who use Java), I actually use the PLT Scheme class system to write code like this.<br>
<br></blockquote><div><br>Coming from the OOP practitioner world, I greatly value classes as an organization, especially the constructor & destructor and the RAII idiom. It's ironic that one of the points against Java is too much boiler plate code, all of which helps the large program to organize themselves.<br>
<br>I am learning to use just plain modules and structs to achieve the organization effect these days. Module provides encapsulation. And struct provides basic inheritance, so what's missing is polymorphism, but that's possible to achieve if the struct themselves carry the functions that they need to call. Also I miss the destructor and explicit finalize. Those comes in very handy for external resource management.<br>
<br>I am probably reinventing the wheel, but that appears to be how I learn :) <br><br>yc<br><br></div></div>