Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!spool.mu.edu!snorkelwacker.mit.edu!stanford.edu!agate!usenet.ins.cwru.edu!po.CWRU.Edu!rkb From: rkb@po.CWRU.Edu (Robert K. Brunner) Newsgroups: comp.sys.handhelds Subject: HP-48 programming problem Message-ID: <1991Apr9.021224.27070@usenet.ins.cwru.edu> Date: 9 Apr 91 02:12:24 GMT Sender: news@usenet.ins.cwru.edu Reply-To: rkb@po.CWRU.Edu (Robert K. Brunner) Organization: Case Western Reserve University, Cleveland, OH (USA) Lines: 27 Nntp-Posting-Host: cwns10.ins.cwru.edu I had a problem debugging a program today, and I was wondering if anyone had encountered the same problem before. The problem isn't a bug, but it is annoying behavior. Suppose you have the following variables: P1: \<< \-> a \<< 'a' INC \>> \>> INC: \<< \-> a \<< a INCR DROP \>> \>> Executing 5 P1 gives INCR Error: Bad Argument Type. If you change the local variable in either of the programs to something different, you get 6, as you would expect. Apparently, INC thinks that the 'a' on the stack refers to the innermost local variable, rather than the one belonging to P1. If this behavior is documented in the manuals, I haven't seen it. By the way, I worked around the problem by using pass-by-value in the real program. Unfortunately, the reason I use a sub-program is that I need the routine in three places, so I've got three extra " 'a' STO " 's, one after each call of the routine. I may change the local variable in the routine, but it bothers me that subroutine calls are not transparent. Suppose someone writes a library that uses a local variable which I unwittingly use elsewhere. Robert