|
whatt ssondays
Joep, thats what i meant.
Some other
The keywords "value" and "const" are a bit confusing. In C (RPG these
seems to be a bit of a strange mix of C and Pascal syntax and semantics)that
all parameters are passed simply by value. The keyword "const" means
you can not change it within the called function (of course you canstill
change it through other references). If you have complex data (not justall
simple datatypes) you can pass a pointer (which is passed by value like
other datatypes). In C it's more common to work with pointers. This isthe
simple, elegant and predictable. You have only one way of passing
parameter, namely "by value". If you don't want to copy lots of data on
stack you simply use &var (%addr(var) in RPG).And
So i think i'm going to use "value" always (not with local procs only).
if i need to pass lots of data (in principle always if i want to passmore
than just a basic type) i pass a pointer. The latter can be done with%addr
in the caller or by definining the parameter as "const". However if iuse
"const" the behavior is not consistent. The compiler decides whether toway
copy the variable or not (and i never want a copy just the const). This
the semantics are the same as in C (except for the use of const), whichreal
comes in handy if i ever want to convert the code to C. I don't see a
downside in this approach, except that it makes more use of pointerswith
which many RPG'ers are not comfortable. And that the semantics of"const"
is not the same as in C. So i'm still in doubt whether to use const (ifi
want to pass a pointer) or use "value" with %addr. The latter case is abit
convoluted but we're used to that in RPG (need at least 6 specs to starta
free form procedure impl without even one parameter). But i can't usethe
const semantics of keyword "const" (like in C) because it mostly alsomeans
"copy".
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.