Previous chapter: Introduction

Dylan manual: Language Overview

2. Language Overview

See Also: Dylan Design Notes: Headers for Dylan Source Files

Dylan is built around two central concepts: objects and functions.

Objects are the data that exist in Dylan programs. Objects are mapped into a class heterarchy. FN3 The class heterarchy describes the inheritance relationships among classes. The class <object> is the root of the heterarchy. Every class inherits from its direct superclasses (except for <object> which has no superclasses). Classes may also have subclasses, which inherit from them, either directly or indirectly. The superclasses[next citation] of a class are the class itself, its direct superclasses, their direct superclasses, and so on back to the class <object>.

Every object in the Dylan world is a direct instance of exactly one class. This class is referred to as the class of the instance. For each object O that is a direct instance of class C, the object O is also an indirect instance of all the superclasses of C (except C itself). (It follows that every object in Dylan is an indirect instance of <object>.) The term general instance means either a direct or indirect instance.

Dylan defines three categories of classes:

Abstract Class
Used to define protocols shared by subclasses, but cannot be used as the first argument to make.abstract class
Instantiable Class
A class that can be used as the first argument to make.instantiable class
Sealed Class
A class that cannot be subclassed.sealed class
Functions are a class of objects used for performing actions in Dylan. Functions correspond to the functions, procedures, methods, and messages of other languages. Dylan supports two classes of functions: methods and generic functions.

A method[next citation] is a basic callable unit of code. It contains a typed argument list and a code body. The types in the argument list are called the specializers of the method. A method can only be called with arguments that match the specializers of the argument list. (In the most common case, the specializer is a class, and the corresponding argument must be a general instance of the class.) When the specializers of a method match a set of arguments, the method is said to be applicable to the arguments. If a method is called with inappropriate arguments, an error is signaled.

A generic function contains zero or more methods. When a generic function is called, the arguments are compared to the specializers of all the methods in the generic function. The method with the most appropriate specializers is run. reference p. 53 In this way, a generic function chooses a method based on the classes and identities of its arguments. This is the basic technique for object-oriented dispatch in Dylan.

In contrast to methods in other object-oriented languages, Dylan methods can be called directly. They do not need to be added to generic functions. Used this way, methods play the role of blocks in Smalltalk and closures in Lisp.

Classes and functions are themselves first-class objects, which can be manipulated by programs.

Structure of Dylan

The Dylan language consists of a core language plus several libraries of useful functionality. The core language is designed to be conceptually minimal, but not to be a useful or complete language. Any useful program will probably use several of the libraries.

The Dylan core language consists of the literal constants and the following named entities:

apply[next citation]
begin[next citation]
bind[next citation]
bind-exit[next citation]
bind-methods[next citation]
define[next citation]
define-class[next citation]
define-generic-function[next citation]
define-method[next citation]
if[next citation]
initialize[next citation]
make[next citation]
method[next citation]
quote[next citation]
set![next citation]
setter[next citation]
slot-initialized?[next citation]
unwind-protect[next citation]
values[next citation]
The libraries specified as part of the Dylan language are as follows:

Extended Control Constructs
provides several syntax forms that define handy notations for familiar control constructs such as conditionals and iteration. Examples include when, or, and select.
Function Meta-Operations
provides reflective and manipulative operations on functions and methods.

Class Meta-Operations
provides reflective and manipulative operations on classes.
provides operations that compare objects for identity, equality, or magnitude.
provides a rich library of classes of aggregate data structures.
provides exception handling mechanisms.
provides numbers.
Symbol and Keyword Meta-Operations
provides access to symbols and keywords by name.

Character Operations
provides a few operations specific to characters.
Functional Operations
provides several useful higher-order functions.
(not in the language specification yet) provides programmers the ability to define their own syntax forms. This will be added. We believe its design should be fully hygienic, yet easy to use and understand.
A number of additional libraries are not defined by the language, but are provided by each implementation in a way consistent with the environment in which that implementation runs. This includes such facilities as the File System, User Interface, etc.

Next chapter: Syntax and Semantics