/tutorial/signal/example1.e

http://github.com/tybor/Liberty · Specman e · 30 lines · 19 code · 5 blank · 6 comment · 0 complexity · 43bb730a3a7b08b203e5366578ed6ca5 MD5 · raw file

  1. class EXAMPLE1
  2. -- Signal example1
  3. -- This example shows a signal which carries an integer value.
  4. -- You may imagine that A is a scrollbar and that you need to be
  5. -- informed each time the value (position) changes so that you can
  6. -- correctly redraw it at the new place.
  7. create {ANY}
  8. make
  9. feature {}
  10. a: A
  11. make
  12. do
  13. create a.make
  14. a.value_changed.connect(agent foo(?))
  15. -- a.value_changed.connect(agent foo); -- syntactically equivalent
  16. a.set_val(3)
  17. a.set_val(5)
  18. end
  19. foo (i: INTEGER)
  20. do
  21. io.put_string(once "New value is ")
  22. io.put_integer(i)
  23. io.put_new_line
  24. end
  25. end -- class EXAMPLE1