|
Hi Scott, I haven't used pointers much, but from what I've heard (your example notwithstanding), it's much easier to trash data unintentionally with pointers than otherwise. What kind of protection is there for pointer usage? Presumably I can't set a data pointer to a procedure pointer, right? But what about basing a 32767 byte field on a pointer, then pointing it to a 1-byte field? Curious, Peter Dow Dow Software Services, Inc. 909 425-0194 voice 909 425-0196 fax From: Scott Klement <klemscot@klements.com> > The reason that I used pointers is because I'm paranoid about writing data > to an area of memory outside the scope of my variable. > > In the data structure example you give here, if I were to pass a PACKED > parameter it'd be only 4 bytes long. If I were to do this: > > c MOVE *ZEROS PARM1 > > 3 zeroes would be put into whatever happened to be in the area of memory > that comes after my parameter. This can cause all sorts of nasty and > hard to debug errors. > > Whereas, the way I was doing it, this can't happen. Worst case scenario, > you'd try to use a field thats still based on a *NULL pointer, which the > system would know is invalid and it could stop your program with an error. > > Granted, if your careful, it won't matter. :) I have to wonder why you > say "why bother with pointers?". IMHO, pointers arent any more of a > bother than data structures are. > > > > On Wed, 8 Mar 2000, Sims, Ken wrote: > > > Hi Scott - > > > > Why bother with pointers? > > > > d parm1 ds 7 > > d zoned1 1 7s 0 > > d packed1 1 4p 0 > > d* > > d myparm1 s 7 0 > > c* > > c *entry plist > > c parm parm1 > > c* > > c if %subst(parm1:1:1) >= '0' > > c eval myparm1 = zoned1 > > c else > > c eval myparm1 = packed1 > > c endif > > > > Ken > > Southern Wine and Spirits of Nevada, Inc. > > Opinions expressed are my own and do not necessarily represent the views of > > my employer or anyone in their right mind. > > > > > > +--- > | This is the RPG/400 Mailing List! > | To submit a new message, send your mail to RPG400-L@midrange.com. > | To subscribe to this list send email to RPG400-L-SUB@midrange.com. > | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. > | Questions should be directed to the list owner/operator: david@midrange.com > +--- __________________________________________________ Do You Yahoo!? Talk to your friends online with Yahoo! Messenger. http://im.yahoo.com +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-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-2025 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.