× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Wow, that is the first time I ever heard (or read) someone describe the
use of pointers in C as 'simple, elegant and predictable'! The fact that C
only passes parameters by value leads to extensive use of pointers, which
first brought us the widespread disease of memory loss and later, as a
remedy, Java :-)

Joep Beckeringh


whatt sson

Joep, thats what i meant.

Some other
The keywords "value" and "const" are a bit confusing. In C (RPG these
days
seems to be a bit of a strange mix of C and Pascal syntax and semantics)
all parameters are passed simply by value. The keyword "const" means
that
you can not change it within the called function (of course you can
still
change it through other references). If you have complex data (not just
simple datatypes) you can pass a pointer (which is passed by value like
all
other datatypes). In C it's more common to work with pointers. This is
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
the
stack you simply use &var (%addr(var) in RPG).

So i think i'm going to use "value" always (not with local procs only).
And
if i need to pass lots of data (in principle always if i want to pass
more
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 i
use
"const" the behavior is not consistent. The compiler decides whether to
copy the variable or not (and i never want a copy just the const). This
way
the semantics are the same as in C (except for the use of const), which
comes in handy if i ever want to convert the code to C. I don't see a
real
downside in this approach, except that it makes more use of pointers
with
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 (if
i
want to pass a pointer) or use "value" with %addr. The latter case is a
bit
convoluted but we're used to that in RPG (need at least 6 specs to start
a
free form procedure impl without even one parameter). But i can't use
the
const semantics of keyword "const" (like in C) because it mostly also
means
"copy".

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.