4.7 Summary
In this chapter, we covered the following:
We defined a class (with define class).
We created an instance (with make).
We read the value of a slot by calling a getter.
We set the value of a slot by using :=, the assignment operator.
We defined a method that returns multiple values (with values), and showed how to initialize multiple local variables (with let).
We showed the syntax of some commonly used elements of Dylan; see Table 4.2.
Table 4.2 Syntax of Dylan elements.
Dylan element
| Syntax example
|
|---|
calling a getter
|
*my-time-of-day*.total-seconds;
|
|
calling a setter
|
*my-time-of-day*.total-seconds := 180;
|
|
keyword
|
total-seconds:
|
|
single-line comment
|
// Text of comment
|
|
multiline comment
|
/* Text of comment that spans more than one line */
|
|
value declaration
|
=> (total-seconds :: <integer>)
|
N Feinberg/S E Keene/R Mathews/P Tucker Withington, DYLAN PROGRAMMING, (c) 1997 Harlequin Inc. Reproduced by permission of Addison-Wesley Longman Publishing Company, Inc. All rights reserved. No further copying, downloading or transmitting of this material is allowed without the prior written permission of the publisher.