Trapping in Dyalog APL v18.0
Posted: Wed Jan 13, 2021 7:30 pm
Hi everyone,
I am migrating an app from Dyalog 17.1 to Dyalog 18.0 and have realized that trapping behavior has changed. I have prepared a code snippet that demonstrates the change. Calling method run results in an infinite loop in Dyalog 18.0, while it works as intended in Dyalog 17.1.
It seems to me, that signalling an error in a Dfns does not terminate the context of the Dfns but rather stops at the current instruction line (as opposed to real functions, where the context of the faulty function is terminated and the instruction pointer is reset to the line in the calling function).
Can someone tell me if this change is intended?
Here is the code:
I am migrating an app from Dyalog 17.1 to Dyalog 18.0 and have realized that trapping behavior has changed. I have prepared a code snippet that demonstrates the change. Calling method run results in an infinite loop in Dyalog 18.0, while it works as intended in Dyalog 17.1.
It seems to me, that signalling an error in a Dfns does not terminate the context of the Dfns but rather stops at the current instruction line (as opposed to real functions, where the context of the faulty function is terminated and the instruction pointer is reset to the line in the calling function).
Can someone tell me if this change is intended?
Here is the code:
Code: Select all
:Class Klasse
∇ run
:Access public
setTrap
run1
∇
∇ setTrap;terminate_str;trap_str;method_to_terminate
:Access private
#.cnt←0 ⍝ Break an infinite loop, when cnt reached 100 in Dyalog APL 18.0
method_to_terminate←'run2'
terminate_str←'⎕←⎕SI ⋄ ⎕TRAP←0⍴⎕TRAP ⋄ →1+↑⎕LC'
trap_str←'#.cnt+←1 ⋄ ⎕←⎕SI ⋄ ⎕TRAP←,⊂999 ''E'' ((⎕IO+''',method_to_terminate,'''≡↑⎕SI)⊃((⎕IO+2)⊃↑⎕TRAP)''',terminate_str,''') ⋄ ⎕trap←(#.cnt<100)⍴⎕trap ⋄ ⎕SIGNAL 999'
⎕TRAP←999 'E'trap_str
∇
∇ run1
:Access private
run2
⎕←'Continue here.'
∇
∇ run2
:Access private
run3
⎕←'fail'
∇
∇ run3
:Access private
{
run4
}0
⎕←'fail'
∇
∇ run4
:Access private
run5
⎕←'fail'
∇
∇ run5
:Access private
⍎'⎕SIGNAL 999'
∇
:EndClass