example-ool.sl 907 B

12345678910111213141516171819202122232425262728293031323334
  1. %
  2. % EXAMPLE-OOL.SL - Examples of the usage of OOL.SL, an "object oriented
  3. % language".
  4. %
  5. % Author: William F. Galway
  6. % Symbolic Computation Group
  7. % Computer Science Dept.
  8. % University of Utah
  9. % Date: 24 July 1982
  10. % Copyright (c) 1982 University of Utah
  11. %
  12. (setf generic-number
  13. (create_class
  14. (value NIL) % Local state is a "value", initially NIL.
  15. % Message table
  16. (
  17. ((gets x) (setf value x)) % Assign argument to local state
  18. ((value) value) % Return the local value
  19. % Raise to a power
  20. ((to-power n)
  21. (let ((p 1))
  22. (for (from i 1 n 1)
  23. % Repeatedly send a "times" message to our "value".
  24. (do (setf p (send_msg value `(times ,p))))
  25. p))))))
  26. (setf complex-number
  27. (create_class
  28. (real-part 0 imag-part 0)
  29. % Message dictionary
  30. ((times y) ....???