Mindy Hello World
Well, the first program anyone should endeavor to write in a new language is, of course, Hello World. Type this into a file called hw-exports.dylan:
Module: dylan-user
define library hello-world
use Dylan;
end library;
define module hello-world
use dylan;
use cheap-io;
use extensions;
end module;
And put this in hw.dylan:
module: Hello-World
// This is the canonical ``hello, world'' demo.
define method main (argv0 :: , #rest noise)
puts("Hello, World.\n");
end;
To compile your program invoke $INSTALL/bin/mindycomp, for example:
% $INSTALL/bin/mindycomp -lhello-world hw-exports.dylan
% $INSTALL/bin/mindycomp -lhello-world hw.dylan
This produces files named hw.dbc and hw-exports.dbc. The .dbc stands for "Dylan Byte Code". To run the program, say:
% $INSTALL/bin/mindy -f hw-exports.dbc -f hw.dbc
It should print "Hello, World." to standard output and then exit.
Note that even the minimal Dylan program has at least two files. This is because in order to do anything much at all, you must access additional libraries, and the only way to set up your namespace is to define your own library and module. But the only way to place code in a module is to use the Module: file header, so two files are required.
Note also that a blank line is required after the Module: file header.