Appendix D

Appendix D - Teach Yourself Scheme in Fixnum Days[Go to...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Teach Yourself Scheme in Fixnum Days [Go to first , previous , next page; contents ; index ] Appendix D A clock for infinity The Guile [ 13 ] procedure alarm provides an interruptable timer mechanism. The user can set or reset the alarm for some time units, or stop it. When the alarm's timer runs out of this time, it will set off an alarm, whose consequences are user-settable. Guile's alarm is not quite the clock of sec 15.1 , but we can modify it easily enough. The alarm's timer is initially stopped or quiescent , ie, it will not set off an alarm even as time goes by. To set the alarm's time-to-alarm to be n seconds, where n is not 0 , run (alarm n) . If the timer was already set (but has not yet set off an alarm), the (alarm n) procedure call will return the number of seconds remaining from the previous alarm setting. If there is no previous alarm setting, (alarm n) returns 0 . The procedure call (alarm 0) stops the alarm's timer, ie, the countdown of time is stopped, the timer becomes quiescent and no alarm will go off. (alarm 0) also returns the seconds remaining from a previous alarm setting, if any. By default, when the alarm's countdown reaches 0, Guile will display a message on the console and exit. More useful behavior can be obtained by using the procedure sigaction , as follows: (sigaction SIGALRM (lambda (sig) (display "Signal ") (display sig) (display " raised.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 4

Appendix D - Teach Yourself Scheme in Fixnum Days[Go to...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online