Table of Contents
The features of Dylan's object system don't map directly onto the
features found in C++. Dylan handles access control using
modules, not private declarations within
individual objects. Standard Dylan has no destructors, but instead relies
upon the garbage collector to recover memory and on exception handling
blocks to recover other resources. Dylan objects don't even have real
member functions.
Despite these oddities, Dylan's object system is at least as powerful as that of C++. Multiple inheritance works smoothly, constructors are rarely needed and there's no such thing as object slicing. Alternate constructs replace the missing C++ features. Quick and dirty classes can be turned into clean classes with little editing of existing code.
Before starting, temporarily set aside any low-level expertise in C++ or Object Pascal. Dylan differs enough that such knowledge can actually interfere with the initial learning process.
Dylan has a large variety of built-in classes. Several of these
represent primitive data types, such as <integer>
and <character>. A few represent
actual language-level entities, such as <class>
and <function>. Most of the others
implement collection classes, similar to those found in C++'s
Standard Template Library. A few of the most important classes are
shown in Figure 4.1, “Several Standard Dylan Classes”.
The built-in collection classes include a number of common data structures. Arrays, tables, vectors, ranges and deques should be provided by all Dylan implementations. The language specification also standardizes strings and byte-strings, certainly a welcome convenience.
Not all the built-in classes may be subclassed. This allows the compiler to heavily optimize code dealing with basic numeric types and certain common collections. The programmer may also mark classes as sealed, restricting how and where they may be subclassed. See Chapter 6, Modules & Libraries for details.