[plt-scheme] defstruct and class?

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sat Jul 26 11:39:04 EDT 2008

Do you want to serialize instances?

Personal preference: I tend to start programming with modules that  
are class-like:

#lang scheme
  ;; structs for datatype Foo
  (define-struct foo (moo bar))
  -- functions
  (define (f a-foo x y z) ...)
  (define (g a-foo x) ...)
  (define (h a-bar) ...)

I almost always use a "with" macro that opens up instances of Foo in  
these functions.

When I see the design need for classes, I switch and it tends to be  
easy. -- Matthias



On Jul 26, 2008, at 7:30 AM, Circular Function wrote:

> I am playing with the Netflix recommendation system which involves  
> 17K+files and massive amounts of data.
>
> I want to represent (and save) the parsed data in various forms and  
> Python like classes would be perfect.
>
> Should I use defstruct or classes? classes seem complicated and not  
> exactly as classes in other languages.
>
> I want to represent Customer as:
>
> class Customer:
>     def __init__(self, idnumber):
>         self.idnbr = idnumber
>         self.reviews = []
>
>     def addReview(self, review):
>         self.reviews.append(review)
>
>     def hasReview(movieId):
>         doSomething
>
>
>
> Går det långsamt? Skaffa dig en snabbare bredbandsuppkoppling.
> Sök och jämför priser hos Kelkoo.
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20080726/383f8ed5/attachment.html>

Posted on the users mailing list.