[plt-scheme] Class methods and class fields

From: Robby Findler (robby at cs.uchicago.edu)
Date: Tue Apr 29 08:43:23 EDT 2008

The PLT Scheme class system is embedded in an ordinary functional
language, so you can just define functions or database connections
outside the class an refer to those variables lexically, eg:

(define db-connection (init-db))
(define my-class%
  (class object%
    (define/public (talk-to-db stuff) ... db-connection ...)


On Tue, Apr 29, 2008 at 7:38 AM, Eddie Sullivan <eddieSull at hotmail.com> wrote:
> Hi.
>  I'm another long-time programmer trying out scheme. I have been working
> with PLT's scheme/class module because I am used to
>  the object oriented way of thinking about programming.
>  In every other language I have used that has classes (Python and the C++
>  family, also [incr tcl] but my memory of that is vague), there is the
>  concept of "class variables", that is, variables that are associated with
>  the class itself rather than with any particular instance, and the similar
>  concept of "class methods." (They're also often called "static", but that
>  term can be confusing, IMO.)
>  It's easy to imagine scenarios where these concepts would be very useful,
> such as a
>  shared resource like a database connection, or simply a usage counter.
>  Perhaps I'm misreading the documentation, but I can't find anything like
> that in scheme/class. Structures have "structure type properties", so the
> idea must be acknowledged to be useful in theory.
>  Is it there and I'm missing it? If not, is there a simple way to implement
> this functionality that I haven't figured out? Or is there a philosophical
> reason why this was considered a bad idea?
>  Thanks!
>  -Eddie Sullivan
>  _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Posted on the users mailing list.