|
Simon wrote: >I don't think you should regret adding pointer support to RPG IV. Giving >us pointers has meant that RPG can now do many things previously >impossible or only posible with difficulty and truly ugly data structures. As I said in my previous note (to Jim), perhaps "regret" was too strong a word. It's probably just a reflection of my frustration in seeing pointers used in places where there are better alternatives. >Four major benefits from having pointers are: > 1/ Based storage which makes processing user spaces easier and >faster than the alternative and gives us access to dynamic storage thus >more flexible array processing This is the "dynamic array" issue. As I've said before, handling undetermined quantities of data is probably better handled in the database, and not within program code. (I like how undetermined quantities of data are handled in other languages like Python, Rexx, Perl, and Ruby. Varying sized lists and hash tables are fundamental data structures in these languages. But then, these have the advantage of being interpreted, not compiled languages.) > 2/ The ability to invoke C-runtime functions including those which >expect char** data types This is not an unreasonable use of pointers, in my opinion. The C-runtime library should be considered a normal part of the RPG programmers tool kit. > 3/ Cleaner code -- there is a valid aphorism regarding coding that >states "Get the data structures correct and the code falls into place". >It manifests itself in general as: > complex data strucures = simpler code > simpler data structures = complex code I agree with the statement "Get the data structures correct and the code falls into place". I've said that many times myself. I don't necessarily agree with your other. Often complex data structures can result in complex code. The key point is getting the data structures "right", which is different that making the data structures complex. I know from experience that there are lots of complicated ways to design your data structures. But there are "good" ways to design the data structures that yield both simple data structures and simple code. For the average RPG programmer, I believe the key issue is getting a proper database design. Complexity seems to happen over time as functionality is added to an application, and the developers cannot afford to redesign existing data structures. > 4/ Function pointers which give us dynamic call-back ability and >therefore the ability to allow procedures to be enhanced or modifed by the >caller -- if they've been designed correctly. Function pointers are a different issue from the current discussion that involves basing pointers. If you're looking at a lot of "call-back" functions in your application, you probably should be using an object-oriented language instead. >Just because certain programmers misuse or misunderstand pointers is no >reason for you to regret providing them. Carpenters cut themselves with >chisels every day but that's no reason to remove chisels from the toolbox. >You cannot protect the fools from themselves and if you try then you >simply irritate the rest of us. And I've got the scars to prove that point! ;-) >I can think of only three peculiarities involved in providing pointer >support: Only three? ;-) > 1/ Not allowing pointer arithmetic in the first release >(thankfully that has been corrected but it was obviously a misguided >attempt to protect RPG programmers from themselves) Pointer arithmetic was indeed added quite a few releases ago. > 2/ Automatically declaring a pointer used in based storage (and >I'm in two minds about that -- I frequently use that ability to advantage >but like others get bitten by misspelling the pointer name which in >reality is no worse than misspelling a field name) Yes, we probably should have required explicit pointer declaration. I often code an initial value on a pointer definition anyways when coding pointers. > 3/ Not allowing BASED(%ADDR(somefield)) (which is likely to be >fixed sometime in the future) Not in the immediate future. But who knows what will be decided on in the next few years? >The RPG compiler team is doing a good job on the whole. There are >certainly peculiar things done and I would certainly do some things >differently but mostly everything you do improves the language (regardless >of what Bob Cozzi would have us believe). > >I would not want to see typed pointers in RPG but I do want to see >user-defined types (even COBOL has that ability!). That's long overdue >and I would spend my entire $100 on that single enhancement. Then we can >move on to overloaded procedures, he says hopefully. I'd far rather see >new features in the language than new ways of doing the same old stuff >(e.g., %CHAIN, %READ, jeez give me a break :) Cheers! Hans Hans Boldt, ILE RPG Development, IBM Toronto Lab, boldt@ca.ibm.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.