So, in "classic" Scheme (up to R5RS), there were no structs/records/classes. You could fake them with a Vector and writing all the accessor methods by hand, but it sucked.
R6RS (as implemented in Chez Scheme) added a much more powerful system with inheritance and constructor methods, but half the Scheme community hates nice things and voted it down. There's a half-assed reimplementation of R6RS in SRFI-99 and sequels, but it still doesn't have read/write mechanisms. R7RS still only ships with SRFI-9 built in. Unbelievable mess.
Chicken has a convenient define-record macro, and read/write methods, but by default uses SRFI-9, and hides SRFI-99 in an egg; so
chicken-install -s srfi-99 and then
(import srfi-99) everywhere, and then write a ton of boilerplate for every type. So I just automated it with Python (doing string parsing in Scheme is more annoying):
Documentation is in the module help (or just read the source, Luke). I use it by writing the Chicken macro
(define-record Point x y), then at shell:
And paste back:
;; (define-record Point x y) (define-record-type Point #t #t (x) (y) ) (define-reader-ctor 'Point make-Point) (define-record-printer (Point p out) (format out "#,(Point ~S ~S)" (Point-x p) (Point-y p) )) ; module exports: ; make-Point Point? Point-x Point-y
Note that none of this really gets me an "object-oriented" system, but records are sufficient for most programs, and inheritance works with define-record-type. There are OOP systems but I don't especially like any of them so I'm passing on them for now.