|
RPG doesn't have typed pointers.
If you decide to manage passing the correct data types yourself,
you're back in the bad old days of CALL + PARM, where the compiler
oculd not do any type checking.
On 5/1/2013 6:14 AM, whatt sson wrote:
...more
if i need to pass lots of data (in principle always if i want to pass
than just a basic type) i pass a pointer. ... I don't see a real
downside in this approach ...
RPG doesn't have typed pointers.
Take this C function
myFn (int *p);
The exact RPG equivalent is
D myFn PR
D p 10i 0
Both the C and RPG prototypes say that the parameter is an integer
passed by reference. The C version can also be stated as "pointer to
integer passed by value". But that's not possible to code in RPG. This
RPG prototype
D myFn PR
D p * value
is not equivalent to the C prototype, because that RPG prototype simply
says "pointer passed by value". The "integer" part of the C prototype is
lost.
If you pass the address of a float to the C function, the C ocmpiler
will complain. If you pass the address of a float to the second RPG
function, the RPG compiler won't care, because you haven't told it to
expect a pointer to an integer.
If you decide to manage passing the correct data types yourself, you're
back in the bad old days of CALL + PARM, where the compiler oculd not do
any type checking.
--
Barbara
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.
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.