The C Object System (COS)

The C Object System: Using C as a High-Level Object-Oriented Language, Laurent Deniau, arxiv 2010.

The C Object System (COS) is a small C library which implements high-level concepts available in Clos, Objc and other object-oriented programming languages: uniform object model (class, meta-class and property-metaclass), generic functions, multi-methods, delegation, properties, exceptions, contracts and closures. [...]

COS is interestingly built around fast multiple dispatch and delegation. It is implemented by a portable C library (C99 CPP required) and build tool. So, it's roughly a CLOSy GObject. Or a multiple dispatch, pruned Objective-C 1.0. No garbage collector. The exceptions are setjmp. The motivation is large-scale scientific code development and maintenance. LGPL. COS is the successor to Object Oriented C (OOC-2.0) and Object Oriented Programming in C (OOPC). The project currently appears alive, about 3 years old, out of CERN, with ~one developer, perhaps limited use, and no community infrastructure beyond SourceForge CVS.

On top of these concepts, it should be easy to implement high order messages, class-predicate dispatch, multiple inheritance, dynamic inheritance, dynamic classes, adaptive object model, reflection and advanced memory management.

COS homepage. Slides.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Discussed on reddit a few months ago

Here's the thread. I looked at the source at the time too, and it was a dizzying maze of macro magic. I did learn some new tricks though, which subsequently lead to a to-be-blogged technique based on a name mangling for writing user friendly polymorphic functions in C (with overloading ala type classes!). Of course, that's only a static dispatch technique, where COS performs dynamic dispatch.

Repackage for other languages?

Might parts of COS be repackaged for C++ and Objective-C, to get fast multi-methods there too? Over unmodified native classes?

Could C extensions for python/ruby/perl/etc be derived, replacing their current unusably-slow toy multi-method modules?