Chapter 2. Expressions & Variables

Table of Contents

Naming Conventions
True and False
The Nature of Variables
Assignment, Equality and Identity
parallel Values
Type Declarations
Module Variables and Constants

Dylan identifiers may contain a greater variety of characters than those of C or Pascal. Specifically, variable names may contain all alphanumeric characters, plus the symbols ! & * < = > | ^ $ % @ _ - + ~ ? /. Identifiers may not begin with the symbols - + ~ ? /, although identifiers may begin with numbers, provided they contain at least two alphabetic characters in a row. As in Pascal, variable names are not case sensitive. Need Dylan Reference Manual footnote here.

This means that (a - b) subtracts one variable from another, whereas (a-b) simply returns the value of the hyphenated variable named a-b. Because of this, infix operators, such as addition, subtraction and equality, must be surrounded by whitespace.

As in C++, Dylan infix operators may also be refered to as functions. In C++, (a + b) could also be written as operator+(a, b). In Dylan, the same expression could be written \+(a, b). In both languages, programmers can use this flexibility to define operators for custom numeric classes.

Naming Conventions

Dylan uses the extra characters permitted in variable names to support a number of standard naming conventions, as shown in Table 2.1, “Naming Conventions”.

Table 2.1. Naming Conventions

<string>a class
insert!mutative function (modifies arguments destructively)
empty?predicate function (tests one or more arguments and returns either true or false)
write-linea two word name
*name*module-level variable