Protobj: Prototype-Delegation Object Model in Scheme

Protobj is a Scheme library that implements a simple prototype-delegation object model, somewhat similar to that of Self, and also related to those of SLIB object and OScheme. Protobj was written mainly as a syntax-rules learning exercise, but also because people ask about prototype object models for Scheme from time to time. Like most object systems, Protobj should be regarded as an amusement. The Protobj library defines both a verbose set of procedures, and terse special syntax.

Protobj is based on objects with named slots that can contain arbitrary values. Object have immediate slots, and single parent objects from which additional slots are inherited. When setting in a child object a slot inherited from the parent, a new immediate slot is created in the child so that the parent is unaffected and the slot is no longer inherited.

Methods are simply closures stored in slots. When a method is applied, the first term of the closure is the receiver object. Unlike Self, getting getting the contents of the slot is distinguished from invoking a method contained in the slot. This distinction was made due to the way first-class closures are often used in Scheme.

An object is cloned by invoking the clone method. The default root object's clone method creates a new child object without any immediate slots, rather than copying any slots. This behavior can be overridden to always copy certain slots, to copy immediate slots, or to copy all inherited slots. An overriding clone method can be implemented to apply its parent's clone method to itself and then set certain slots in the new child appropriately.

Protobj requires R5RS, SRFI-9, SRFI-23, and SRFI-39.

See documentation for cites and more info...

To be added to the moderated scheme-announce email list, ask neil@neilvandyke.org .

The current version of Protobj is 0.2 (2005-06-19).

You can download file protobj.scm, Scheme source code.

You can download file protobj.html, documentation in HTML format.

You can download file protobj.pdf, documentation in PDF format.

You can download file protobj.plt, a packaging for PLT Scheme.

Site © 1994-2008 Neil Van Dyke   neil@neilvandyke.org    XHTML 1.0 Strict  CSS2    Legal