3.1 Method definitions
In Dylan, we define methods — a method is a kind of function. We define a simple method, say-hello, as follows:
define method say-hello ()
format-out("hello, world\n");
end;
We call say-hello as follows:
? say-hello(); hello, world
We use define method to define a method named say-hello. Just after the name say-hello, we specify the method's parameter list, (). The parameter list of this method is empty, meaning that this method takes no arguments. The call to say-hello provides an empty argument list, meaning that there are no arguments in the call.
The body of the say-hello method has one expression — a call to format-out. A method returns whatever is returned by the expression executed last in its body. In general, a method can return a single value, multiple values, or no value at all. The say-hello method returns what format-out returns — no value at all. In the call to say-hello, we see the output of format-out in the listener; we see output and not a returned value (because no value is returned).
Usage note: In this chapter, we define methods that call the |




