[Next] [Previous] [Top] [Index]

Dylan Reference Manual

Contents


Contents
Copyrights and Trademarks
About This Book
1 - Introduction
Background and Goals
Language Overview
Manual Notation
2 - Syntax
Overview
Libraries and Modules
Bindings
Macros
Bodies
Definitions
Local Declarations
Expressions
Statements
Parameter Lists
Lexical Syntax
Special Treatment of Names
Escaping Names
Function Call Shorthand
Top-Level Definitions
Dylan Interchange Format
language: language-name [Header keyword]
module: module-name [Header keyword]
author: text [Header keyword] copyright: text [Header keyword] version: text [Header keyword]
Naming Conventions
3 - Program Structure
Modules
Defining Module Bindings
Libraries
4 - Program Control
Overview
Function Calls
General Syntax
Slot Reference
Element Reference
Operators
Assignment
Conditional Execution
True and False
Iteration
Iteration Statements
Tail Recursion
Non-Local Exits and Cleanup Clauses
Multiple Values
Order of Execution
Execution Order Within Expressions
5 - Types and Classes
Overview
The Type Protocol
Base Types and Pseudosubtypes
Type Disjointness
Classes
Features of Classes
Creating Classes
Class Inheritance
Computing the Class Precedence List
Slots
Slot Inheritance
Slot Specifications
Init Specifications
Init Keywords
Slot Allocation
Constant Slots
Specializing Slots
Overriding Slots in Subclasses
Using Slots
Instance Creation and Initialization
Overview
Additional Behavior of Make and Initialize
Initialization of Class Allocated Slots
Testing the Initialization of a Slot
Inherited Slot Specifications
Initialization Argument Specifications
Initialization Argument Inheritance
Singletons
Union Types
Limited Types
Limited Type Constructor
Limited Integer Types
Limited Integer Type Protocol
Limited Collection Types
6 - Functions
Overview
Generic Functions
Methods
Methods in Generic Functions
Local Methods
Bare Methods
Closures
Parameter Lists
Kinds of Parameters
Kinds of Parameter Lists
Specializing Required Parameters
Keyword Parameters
Types for Keyword Parameters
Result Values
Parameter List Congruency
Parameter Lists of Implicitly Defined Generic Functions
Method Dispatch
Method Specificity
Calling Less Specific Methods
Passing Different Arguments to Next-Method
The Next-Method Parameter
Operations on Functions
7 - Conditions
Background
Overview
Signalers, Conditions, and Handlers
Exception Handling
Stack Model
Recovery and Exits
Restarts
Recovery Protocols
Condition Messages
Introspective Operations
8 - Collections
Overview
The Iteration Protocol
Collection Keys
Iteration Stability and Natural Order
Mutability
Collection Alteration and Allocation
Collection Alignment
Defining a New Collection Class
Tables
Element Types
Limited Collection Types
Element Type Subclassing
Creating Limited Collection Types
Uninstantiable Limited Collection Types
Instantiable Limited Collection Types
9 - Sealing
Overview
Explicitly Known Objects
Declaring Characteristics of Classes
Declaring Characteristics of Generic Functions
Define Inert Domain
Rationale
Pseudosubtype Examples
Abbreviations for Define Inert Domain
Implied Restrictions on Method Definitions
10 - Macros
Overview
Compilation and Macro Processing
Extensible Grammar
Definition Macros
Statement Macros
Function Macros
Macro Names
Rewrite Rules
Patterns
Special Rules for Definitions
Special Rules for Statements
Special Rules for Function Macros
Pattern Variable Constraints
Intermediate Words
Templates
Auxiliary Rule Sets
Hygiene
Intentional Hygiene Violation
Hygiene Versus Module Encapsulation
Rewrite Rule Examples
Statement Macros
Begin
Block
Case
For
If
Method
Select
Unless
Until
While
Definition Macros
Define Class
Define Constant
Define Domain
Define Generic
Define Library
Define Method
Define Module
Define Variable
Additional Examples
Test and Test-setter
Transform!
Formatting-table
With-input-context
Define Command
Get-resource
Completing-from-suggestions
Define Jump-instruction
11 - The Built-In Classes
Overview
Objects
<object> [Open Abstract Class]
Types
Types
<type> [Sealed Abstract Class]
Classes
<class> [Sealed Instantiable Class]
Singletons
<singleton> [Sealed Instantiable Class]
Simple Objects
Characters
<character> [Sealed Class]
Symbols
<symbol> [Sealed Class]
Booleans
<boolean> [Sealed Class]
Numbers
Numbers
<number> [Open Abstract Class]
Complex Numbers
<complex> [Sealed Abstract Class]
Reals
<real> [Sealed Abstract Class]
Floats
<float> [Sealed Abstract Class]
<single-float> [Sealed Class]
<double-float> [Sealed Class]
<extended-float> [Sealed Class]
Rationals
<rational> [Sealed Abstract Class]
Integers
<integer> [Sealed Class]
Collections
Collections
<collection> [Open Abstract Class]
Explicit Key Collections
<explicit-key-collection> [Open Abstract Class]
Sequences
<sequence> [Open Abstract Class]
Mutable Collections
<mutable-collection> [Open Abstract Class]
<mutable-explicit-key-collection> [Open Abstract Class]
<mutable-sequence> [Open Abstract Class]
Stretchy Collections
<stretchy-collection> [Open Abstract Class]
Arrays
<array> [Open Abstract Instantiable Class]
Vectors
<vector> [Open Abstract Instantiable Class]
<simple-vector> [Sealed Abstract Instantiable Class]
<simple-object-vector> [Sealed Instantiable Class]
<stretchy-vector> [Open Abstract Instantiable Primary Class]
Deques
<deque> [Open Abstract Instantiable Primary Class]
Lists
<list> [Sealed Instantiable Abstract Class]
<pair> [Sealed Instantiable Class]
<empty-list> [Sealed Instantiable Class]
Ranges
<range> [Open Abstract Instantiable Primary Class]
Strings
<string> [Open Abstract Instantiable Class]
<byte-string> [Sealed Instantiable Class]
<unicode-string> [Sealed Instantiable Class]
Tables
<table> [Open Abstract Instantiable Primary Class]
<object-table> [Open Abstract Instantiable Class]
Functions
Functions
<function> [Sealed Abstract Class]
Generic Functions
<generic-function> [Sealed Instantiable Class]
Methods
<method> [Sealed Class]
Conditions
Conditions
<condition> [Open Abstract Class]
Serious Conditions
<serious-condition> [Open Abstract Class]
Errors
<error> [Open Abstract Class]
<simple-error> [Sealed Instantiable Class]
<type-error> [Sealed Instantiable Class]
<sealed-object-error> [Sealed Class]
Warnings
<warning> [Abstract Class]
<simple-warning> [Sealed Instantiable Class]
Restarts
<restart> [Open Abstract Class]
<simple-restart> [Sealed Instantiable Class]
Aborts
<abort> [Sealed Instantiable Class]
12 - The Built-In Functions
Overview
Constructing and Initializing Instances
General Constructor
make [Open Generic Function]
make class #rest supplied-init-args #key Þ object [G.F. Method]
make (singleton <array>) #key dimensions fill Þ array [G.F. Method]
make (singleton <vector>) #key size fill Þ simple-object-vector [G.F. Method] make (singleton <simple-vector>) #key size fill Þ simple-object-vector [G.F. Method]
make (singleton <list>) #key size fill Þ list [G.F. Method]
Initialization
initialize [Open Generic Function]
initialize object #key Þ object [G.F. Method]
slot-initialized? [Open Generic Function]
Specific Constructors
list [Function]
pair [Function]
range [Function]
singleton [Function]
limited [Function]
limited (singleton <integer>) #key min max Þ type [G.F. Method]
limited (singleton <collection>) #key of size Þ type [G.F. Method] limited (singleton <explicit-key-collection>) #key of size Þ type [G.F. Method] limited (singleton <mutable-collection>) #key of size Þ type [G.F. Method] limited (singleton <stretchy-collection>) #key of size Þ type [G.F. Method] limited (singleton <mutable-explicit-key-collection>) #key of size Þ type [G.F. Method] limited (singleton <sequence>) #key of size Þ type [G.F. Method] limited (singleton <mutable-sequence>) #key of size Þ type [G.F. Method]
limited (singleton <table>) #key of size Þ type [G.F. Method] limited (singleton <object-table>) #key of size Þ type [G.F. Method]
limited (singleton <array>) #key of size dimensions Þ type [G.F. Method]
limited (singleton <vector>) #key of size Þ type [G.F. Method]
limited (singleton <simple-vector>) #key of size Þ type [G.F. Method] limited (singleton <stretchy-vector>) #key of Þ type [G.F. Method] limited (singleton <deque>) #key of Þ type [G.F. Method]
limited (singleton <string>) #key of size Þ type [G.F. Method]
limited (singleton <range>) #key of Þ type [G.F. Method]
type-union [Function]
vector [Function]
Equality and Comparison
Not and Identity
~ [Function]
Equality Comparisons
== [Function]
~== [Function]
= [Open Generic Function]
object1 = object2 Þ boolean [G.F. Method]
complex1 = complex2 Þ boolean [G.F. Method]
collection1 = collection2 Þ boolean [G.F. Method]
sequence1 = sequence2 Þ boolean [G.F. Method]
list1 = list2 Þ boolean [G.F. Method]
list = sequence Þ boolean [G.F. Method] sequence = list Þ boolean [G.F. Method]
range1 =range2 Þ boolean [G.F. Method]
~= [Function]
Magnitude Comparisons
< [Open Generic Function]
real1 < real2 Þ boolean [G.F. Method]
character1 < character2 Þ boolean [G.F. Method]
string1 < string2 Þ boolean [G.F. Method]
> [Function]
<= [Function]
>= [Function]
min [Function]
max [Function]
Arithmetic Operations
Properties
odd? [Function]
even? [Function]
zero? [Open Generic Function]
zero? complex Þ boolean [G.F. Method]
positive? [Open Generic Function]
positive? real Þ boolean [G.F. Method]
negative? [Open Generic Function]
negative? real Þ boolean [G.F. Method]
integral? [Open Generic Function]
integral? object Þ false [G.F. Method]
integral? real Þ boolean [G.F. Method]
Arithmetic Operations
+ [Open Generic Function]
complex1 + complex2 Þ complex [G.F. Method]
* [Open Generic Function]
complex1 * complex2 Þ complex [G.F. Method]
- [Open Generic Function]
complex1 - complex2 Þ complex [G.F. Method]
/ [Open Generic Function]
complex1 / complex2 Þ complex [G.F. Method]
negative [Open Generic Function]
negative real1 Þ real2 [G.F. Method]
floor [Function]
ceiling [Function]
round [Function]
truncate [Function]
floor/ [Function]
ceiling/ [Function]
round/ [Function]
truncate/ [Function]
modulo [Function]
remainder [Function]
^ [Open Generic Function]
complex1 ^ complex2 Þ number [G.F. Method]
abs [Open Generic Function]
abs complex1 Þ complex [G.F. Method]
logior [Function]
logxor [Function]
logand [Function]
lognot [Function]
logbit? [Function]
ash [Function]
lcm [Function]
gcd [Function]
Coercing and Copying Objects
identity [Function]
values [Function]
General Coercion Function
as [Open Generic Function]
as collection-type collection Þ instance-of-collection-type [G.F. Method]
as (singleton <integer>) character Þ integer [G.F. Method]
as (singleton <character>) integer Þ character [G.F. Method]
as (singleton <symbol>) string Þ symbol [G.F. Method]
as (singleton <string>) symbol Þ string [G.F. Method]
Coercing Case
as-uppercase [Open Generic Function]
as-uppercase character Þ uppercase-character [G.F. Method]
as-uppercase string Þ new-string [G.F. Method]
as-uppercase! [Open Generic Function]
as-uppercase! string Þ string [G.F. Method]
as-lowercase [Open Generic Function]
as-lowercase character Þ lowercase-character [G.F. Method]
as-lowercase string Þ new-string [G.F. Method]
as-lowercase! [Open Generic Function]
as-lowercase! string Þ string [G.F. Method]
Copying Objects
shallow-copy [Open Generic Function]
shallow-copy collection Þ new-collection [G.F. Method]
type-for-copy [Open Generic Function]
type-for-copy object Þ type [G.F. Method]
type-for-copy mutable-collection Þ type [G.F. Method]
type-for-copy limited-collection Þ type [G.F. Method]
type-for-copy range Þ <list> [G.F. Method]
type-for-copy limited-range Þ <list> [G.F. Method]
Collection Operations
Collection Properties
empty? [Open Generic Function]
empty? collection Þ boolean [G.F. Method]
size [Open Generic Function]
size collection Þ integer-or-false [G.F. Method]
size array Þ size [G.F. Method]
size list Þ integer-or-false [G.F. Method]
size range Þ size [G.F. Method]
size table Þ size [G.F. Method]
size-setter [Open Generic Function]
size-setter integer stretchy-sequence Þ integer [G.F. Method]
rank [Open Generic Function]
rank array Þ rank [G.F. Method]
row-major-index [Open Generic Function]
row-major-index array #rest subscripts Þ index [G.F. Method]
dimensions [Open Generic Function]
dimensions vector Þ sequence [G.F. Method]
dimension [Open Generic Function]
dimension array axis Þ dimension [G.F. Method]
key-test [Open Generic Function]
key-test sequence Þ test-function [G.F. Method]
key-test table Þ test-function [G.F. Method]
key-sequence [Open Generic Function]
Selecting Elements
element [Open Generic Function]
element simple-vector index #key default Þ element [G.F. Method]
element unicode-string index #key default Þ character [G.F. Method]
element byte-string index #key default Þ character [G.F. Method]
element table key #key default Þ element [G.F. Method]
element-setter [Open Generic Function]
element-setter new-element simple-vector index [G.F. Method] Þ new-element
element-setter new-value table key [G.F. Method]
element-setter character unicode-string index Þ character [G.F. Method]
element-setter character byte-string index Þ character [G.F. Method]
aref [Open Generic Function]
aref array #rest indices Þ element [G.F. Method]
aref-setter [Open Generic Function]
aref-setter new-value array #rest indices Þ new-value [G.F. Method]
first [Function]
second [Function]
third [Function]
first-setter [Function]
second-setter [Function]
third-setter [Function]
last [Open Generic Function]
last-setter [Open Generic Function]
head [Function]
tail [Function]
head-setter [Function]
tail-setter [Function]
Adding and Removing Elements
add [Open Generic Function]
add! [Open Generic Function]
add! deque new-value Þ deque [G.F. Method]
add! stretchy-vector new-element Þ stretchy-vector [G.F. Method]
add! list element Þ pair [G.F. Method]
add-new [Open Generic Function]
add-new! [Open Generic Function]
remove [Open Generic Function]
remove! [Open Generic Function]
remove! deque value #key test count Þ deque [G.F. Method]
remove! stretchy-vector element #key test count [G.F. Method] Þ stretchy-vector
remove! list element #key test count Þ list [G.F. Method]
push [Open Generic Function]
pop [Open Generic Function]
push-last [Open Generic Function]
pop-last [Open Generic Function]
Reordering Elements
reverse [Open Generic Function]
reverse range Þ new-range [G.F. Method]
reverse! [Open Generic Function]
reverse! range Þ range [G.F. Method]
sort [Open Generic Function]
sort! [Open Generic Function]
Set Operations
intersection [Open Generic Function]
intersection range1 range2 #key test Þ range [G.F. Method]
union [Open Generic Function]
remove-duplicates [Open Generic Function]
remove-duplicates! [Open Generic Function]
Subsequence Operations
copy-sequence [Open Generic Function]
copy-sequence range #key start end Þ new-range [G.F. Method]
concatenate [Function]
concatenate-as [Function]
replace-subsequence! [Open Generic Function]
subsequence-position [Open Generic Function]
Mapping and Reducing
Simple Mapping
do [Function]
map [Function]
map-as [Function]
map-into [Function]
any? [Function]
every? [Function]
Extensible Mapping Functions
reduce [Open Generic Function]
reduce1 [Open Generic Function]
choose [Open Generic Function]
choose-by [Open Generic Function]
Other Mapping Functions
member? [Open Generic Function]
member? val range #key test Þ boolean [G.F. Method]
find-key [Open Generic Function]
remove-key! [Open Generic Function]
remove-key! table key Þ table [G.F. Method]
replace-elements! [Open Generic Function]
fill! [Open Generic Function]
The Iteration Protocol
forward-iteration-protocol [Open Generic Function]
forward-iteration-protocol table Þ initial-state limit next-state finished-state? current-key current-element current-element-setter copy-state [G.F. Method]
backward-iteration-protocol [Open Generic Function]
The Table Protocol
table-protocol [Open Generic Function]
table-protocol object-table Þ test-function hash-function [G.F. Method]
merge-hash-codes [Function]
object-hash [Function]
Reflective Operations on Types
instance? [Function]
subtype? [Function]
object-class [Function]
all-superclasses [Function]
direct-superclasses [Function]
direct-subclasses [Function]
Functional Operations
compose [Function]
complement [Function]
disjoin [Function]
conjoin [Function]
curry [Function]
rcurry [Function]
always [Function]
Function Application
apply [Function]
Reflective Operations on Functions
generic-function-methods [Function]
add-method [Function]
generic-function-mandatory-keywords [Function]
function-specializers [Function]
function-arguments [Function]
function-return-values [Function]
applicable-method? [Function]
sorted-applicable-methods [Function]
find-method [Function]
remove-method [Function]
Operations on Conditions
Signaling Conditions
signal [Function]
error [Function]
cerror [Function]
break [Function]
check-type [Function]
abort [Function]
Handling Conditions
default-handler [Open Generic Function]
default-handler condition Þ false [G.F. Method]
default-handler serious-condition Þ {does not return} [G.F. Method]
default-handler warning Þ false [G.F. Method]
default-handler restart Þ {does not return} [G.F. Method]
restart-query [Open Generic Function]
return-query [Open Generic Function]
Introspection on Conditions
do-handlers [Function]
return-allowed? [Open Generic Function]
return-description [Open Generic Function]
condition-format-string [Function]
condition-format-arguments [Function]
type-error-value [Function]
type-error-expected-type [Function]
13 - Other Built-In Objects
Other Built-In Objects
#t [<boolean>]
#f [<boolean>]
$permanent-hash-state [<object>]
#() [<empty-list>]
14 - The Built-In Macros and Special Operators
Overview
Definitions
define variable [Definition]
define constant [Definition]
define generic [Definition]
define method [Definition]
define class [Definition]
define module [Definition]
define library [Definition]
define inert domain [Definition]
define macro [Special Definition]
Local Declarations
let [Local Declaration]
local [Local Declaration]
let handler [Local Declaration]
Statements
Conditionals
if [Statement]
unless [Statement]
case [Statement]
select [Statement]
Iteration Constructs
while [Statement]
until ( test ) [Statement]
for [Statement]
begin [Statement]
block [Statement]
Dynamic Extent of Block Features
Intervening Cleanup Clauses
Restrictions on the use of exit procedures
method [Statement]
Special Operators
Assignment
:= [Special Operator]
Assignment to a binding
Assignment to a function or function macro
Assignment to element references
Conditional Execution
| [Special Operator]
& [Special Operator]
A - BNF
General Notes
Lexical Notes
Lexical Grammar
Comments
Tokens
Reserved Words
Names, Symbols and Keywords
Operators
Character and String Literals
Numbers
Phrase Grammar
Program Structure
Property Lists
Fragments
Definitions
Local Declarations
Expressions
Statements
Methods
Macro Definitions
Patterns
Templates
Auxiliary Rule Sets
Glossary
Index
Colophon

Dylan Reference Manual - 17 OCT 1995
[Next] [Previous] [Top] [Index]

Generated with Harlequin WebMaker