An APL Traceguide Program Zalman Rubinstein Department of Mathematics and Computer Science University of Haifa H a i f a 31905, I s r a e l Bitnet: RSMA407@HAIFAUVM F a x : 9724 244854 W e shall describe here an A P L 2 function which traces a given A P L p r o g r a m at arbitrary points selected by the user and w h i c h has several advantages over standard utilities such as DTRACE, DSTOP, or even interactive debuggers. T o apply the traceguide the user places the separator character "a" in his p r o g r a m at any location w h i c h returns an assignable result, typically to the right of any "÷" or to the left of any operator, variable or function application w h i c h returns a result. The TRACEGUIDE program performs the following tasks: 1. E n u m e r a t e s t h e u s e r d e f i n e d t r a c i n g s p o t s a n d returns the user defined function character representation under the alias "A" with the enum e r a t i o n e m b e d d e d in t h e f o r m m a n w h e r e m and n are positive integers. 2. F o r e v e r y m A n , T R A C E G U I D E p r i n t s t h e r e s u l t obtained from the standard function DISPLAY for APL2 and additional information placed on both sides of the standard box. 3. I f t h e p r o g r a m d o e s n o t p a s s a c e r t a i n t r a c e s p o t t h e c o r r e s p o n d i n g p l a c e i n d i c a t i o n m a n is omitted from the result. 4. I f t h e p r o g r a m v i s i t s k , k > I times at man all t h e k r e s u l t s o b t a i n e d t h e r e a r e l i s t e d consecutivcly with the visit number attached to the r i g h t - h a n d s i d e o f t h e box. 5. At the completion of the listing of all the traces obtained, T R A C E G U I D E lists the user's original function under the p s e u d o n y m "A" with all the user's selected tracing spots m a r k e d by the symbols m a n , w h e r e m indicates the line n u m b e r of the user's function and n is the trace n u m b e r in the n-th line counted from left to right. 6_ T h e user's function with the "a" m a r k s is retained in any case of suspension, interruption or error. T h e user can then modify the tracing spots by editing and restart T R A C E G U I D E or reclaim the original function by a trivial utility A C L E A N 'fnname ', not listed here. T R A C E G U I D E is a dyadic function w h o s e left: a r g u m e n t is a positive integer limiting the n u m b e r of results combined at each tracing spot. T h e right a r g u m e n t of T R A C E G U I D E is a character scalar or vector containing the minimal code needed to run the user's function in immediate execution mode. T R A C E G U I D E is d e s i g n e d p r i m a r i l y to h e l p analyze running programs (correctly or incorrectly) r a t h e r t h a n d e b u g g i n g p r o g r a m s f o r s y n t a x errors_ Nevertheless the user may experiment with nonrunning programs by looking at the global rankthree array AmatA for a l i s t i n g o f all p a r t i a l results accumulated before the interruption or suspension. The first two dimensions of the above a r r a y c o r r e s p o n d to t h e t r a c i n g c o o r d i n a t e s a n d t h e t h i r d is t h e d e s i r e d c o n t e n t s . The case of a misp l a c e d " a " b y t h e u s e r is e a s y t o d e t e c t b y a S Y N T A X ERROR with a line number indicated. C o m m o n p o s s i b l e e r r o r s , in p l a c i n g " a " a r e : a. b. placing it to the left of a "÷" placing it between operators or variables consisting of m o r e than one symbol, e.g., " + a / " ; " I a 2 " ; or ", a[ 1 3" placing an "a" to the left of a non-assignable item such as a function n a m e not returning a result C. T o review the tracing spots one can edit or list the original function, or look at the contents of the global variable A_TREPS. Recursive functions m a y be traccguided in two distinct ways: a. Full recursive trace using the original function for checking boundary conditions. One pass recursive trace using the funct i o n u n d e r a n alias. This pass may be h e l p f u l w h e n l o o k i n g for t h e i n d u c t i v e definition. b. T h e f u n c t i o n T R A C E G U I D E w a s w r i t t e n in A P L ~ P L U S / I I V e r s i o n 4.0 a n d A P L ~ P L U S P C V e r s i o n 7.1. A l i s t i n g w i l l b e s e n t b y m a i l o r f a x u p o n request. ⢠June 1993 - Volume 23, Number 4
/lp/association-for-computing-machinery/an-apl-traceguide-program-dBemIbHGVT