|
>Date: Wed, 7 Feb 2001 00:48:19 -0600 (CST) >From: Scott Klement <klemscot@klements.com> > >To be honest with you, this surprised me as well. He really should be >getting "pointer not set for location referenced" or similar message when >XTEST2 is first called. > >It seems to me that the addresses of the parameters should be *NULL if >they weren't ever SET by passing parms to the procedure. The fact that >they happened to point to the same area of memory that the previous >procedure pointed to seems like an extraordinary coincidence! > >This implies that when the module is loaded into memory that it's not >initializing its variables to NULL, as I believe that it should. > >I'd be interested in what Barbara & Hans have to say. Scott, when parameters are passed by reference, the procedure receives a pointer to the actual parameter. If the compiler were to initialize that pointer to null, no parameters could ever be received. By default, ILE procedures have no idea how many parameters were passed. To get that information, an operational descriptor has to be passed (not an OPDESC one, just a minimal one giving the number of parms). RPG and CL always pass this minimal operational descriptor (RPG had to, to support *PARMS), but C and COBOL only do it if the programmer requests it. RPG only uses it to provide the value of %parms though. RPG doesn't copy the parameters to some other storage. It gives you direct access to the parameters as they were passed. Mark, when I tried this with a CALL, I indeed got a "pointer or parameter error". That's what I expected, because with a CALL, the number of parameters is always available; for a CALL, RPG has to copy the parameter pointers to its own storage anyway (I forget why), and it only copies the parameters that were actually passed, and sets the other local parameter pointers to null. Regarding bug or feature, I don't think it's either. I think it would be great if the ILE environment could provide something that I don't think is available anywhere else, namely runtime checking of parameters. But the system works the way it works. The existence of %parms and *PARMS implies that the system won't prevent you from accessing parameters that are not passed; the fact that failure to check %parms sometimes causes a nice pointer-not-set error doesn't mean that problems from not checking %parms are limited to that error. Barbara Morris +--- | This is the Midrange System Mailing List! | To submit a new message, send your mail to MIDRANGE-L@midrange.com. | To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com. | To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.