Define the function below. To run it, enter: foo 'Run'
The Timer will fire. The onTimer handler erases the Timer, but the Timer fires again and this time the program blows up because the Timer doesn't actually exist anymore. This seems like a bug to me.
Code: Select all
foo arg
⍝ Show that erasing a timer doesn't stop it from firing.
⍝ Using Dyalog APL/W-64 Version 19.0.49048
:IF arg≡'Run'
'timer' ⎕WC 'Timer' ('Interval' 1000) ('Event' 'onTimer' 'foo')
:ELSEIF 'Timer'≡2⊃arg
'' ⋄ 'Timer ',(⍕↑arg),' fired: ⎕NC of timer is: ',⎕NC ⍕↑arg
⎕CS 'timer' ⍝ Switch namespace to the timer (blows up the second time around).
'⎕NC of #.timer before ⎕EX: ',⍕⎕NC '#.timer'
'Namespace before ⎕EX of #.timer is: ',⍕⎕THIS
⍝ In a real program some stuff would happen here.
⍝⍝⍝ #.timer.Active←0 ⍝ This stops the problem, but it shouldn't be necessary.
⎕EX '#.timer' ⍝ Erase the timer.
'#.timer has been ERASED'
'⎕NC of #.timer after ⎕EX: ',⍕⎕NC '#.timer'
'Namespace after ⎕EX of #.timer is: ',⍕⎕THIS
⎕DQ ''
:ENDIF