[plt-scheme] imperative vs functional

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Wed Nov 5 19:05:07 EST 2008

I don't have time to look through the code BUT world.ss wasn't  
intended for OO approaches at all.

There is an alternative OO framework for world, which we use for "how  
to design classes". Here is the rough idea:

abstract world class
  define abstract/void methods:
  -- onTick
  -- onKey
  -- onMouse
  -- draw
  plus lots of "real" methods that do the set!'y work

then you derive a class that overrides the four "hook" methods with  
methods that accomplish something.

1. In general, this looks more compact than world.ss code, because  
"this" (aka self) just is the right "thing".

2. You will retain the problem of desconstructing and reconstructing  
a new object every time around.

3. BUT, if you feel you need to replace this with real state, you can  
create just about the right mix.

-- Matthias

On Nov 4, 2008, at 1:47 PM, jeeve wrote:

> I made a little program with DrScheme and world.ss teachpack
> my goal is to try to use the functional programming concept mixin
> object oriented programming
> I 'm french beginner in Scheme...
> source code (imperative OO) is here :
> http://jvjulien.free.fr/site/scheme/ping-pong/ping-pong.ss
> and the equivalent (functional / imperative OO) code test is here :
> http://jvjulien.free.fr/site/scheme/ping-pong/ping-pong-ft.ss
> the second version obliges methods to create a new object instance at
> each call. so it's necessary to initialize each fields of this new
> object... if it's a complex class, that does not seem very
> effective...
> exist there a method to reconcile the two approaches (OO and
> functional) ?
> thanks
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Posted on the users mailing list.