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 <demo1> (<object>) slot s :: <integer>; end class <demo1>; define class <demo2> (<object>) slot s :: <integer>, init-value: 3; end class <demo2>; define class <demo3> (<object>) slot s :: <integer>, init-keyword: s:; end class <demo3>; define class <demo4> (<object>) slot s :: <integer>, init-function: method () princ ("initial value> "); read(); end method; end class <demo4>; define class <demo5> (<object>) slot s :: <integer>, required-init-keyword: s:; end class <demo5>; define class <button> (<object>) slot t :: <toggle>, init-keyword: toggle:; end class <button>; define method press (b :: <button>) print ("pressed button"); end method press; define class <toggle> (<object>) slot value :: <boolean>, init-value: #f; end class <toggle>; define method switch (t :: <toggle>) t.value := ~ t.value; end switch; define class <thing> (<object>) slot button :: <button>; slot toggle :: <toggle>; end class <class>; define method main () let thing = make (<thing>); 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>) thing.button := make (<button>); thing.toggle := make (<toggle>); end method initialize; define method press (b :: <button>) print ("pressed button"); switch (b.t); end method press; define method initialize (thing :: <thing>) thing.toggle := make (<toggle>); thing.button := make (<button>, toggle: thing.toggle); end method initialize;
This document is copyright 1996 by Joseph N. Wilson.