Lecture of 9 February 1996
This page is evolving to turn into a real lecture.
Right now, I've included all the code I showed in class.
module: dylan
define class ()
slot s :: ;
end class ;
define class ()
slot s :: , init-value: 3;
end class ;
define class ()
slot s :: , init-keyword: s:;
end class ;
define class ()
slot s :: ,
init-function: method ()
princ ("initial value> ");
read(); end method;
end class ;
define class ()
slot s :: , required-init-keyword: s:;
end class ;
define class ()
slot t :: , init-keyword: toggle:;
end class ;
define method press (b :: )
print ("pressed button");
end method press;
define class ()
slot value :: , init-value: #f;
end class ;
define method switch (t :: )
t.value := ~ t.value;
end switch;
define class ()
slot button :: ;
slot toggle :: ;
end class ;
define method main ()
let thing = make ();
let x = read-char ();
until (x == 'q')
select (x)
't' => press (thing.button);
'p' => print (thing.toggle);
otherwise => print ("Huh?");
end select;
x := read-char (); // to discard carriage return
x := read-char ();
end until;
values (); // to return no printable value
end method main;
define method initialize (thing :: )
thing.button := make ();
thing.toggle := make ();
end method initialize;
define method press (b :: )
print ("pressed button");
switch (b.t);
end method press;
define method initialize (thing :: )
thing.toggle := make ();
thing.button := make (, toggle: thing.toggle);
end method initialize;
This document is copyright 1996 by Joseph N. Wilson.