×

Good News Everybody!

The new search engine is LIVE!

Please report any problems to david (at) midrange.com.




Scott,

ding, ding, ding!  thanks.  while the light in my head is not 100 watts
yet, it's at least 70.

<snip>

> > 1. const means you are passing the value and don't expect it to change
or
> > need it to be returned when the function ends.

> const means you're passing by reference, not value.  Otherwise, you're
> right.

right - i saw that after I posted it - 'value' was misleading.

<snip>

> What about CONST, you say?  Well, CONST is a different way of saying
> "read-only reference."   The parameter is passed by reference, but you're
> not allowed to make any changes to it.  Thus, "read-only."

so, you're saying that if you pass a parm 'const', changing that variable
locally is verboten.

ok then...

<snip>

>    If you need to change your local copy only, or if the variable is
>    smaller than 16-bytes long, pass it by value.
>    If you don't need to change it at all, and it's larger than 16-bytes
>    long, pass it by "read-only reference", aka CONST.

if you have a rather large string that you might want to change locally,
does it matter whether you pass by value and change in-line, or
const/reference and move it to a locally defined variable for manipulation
- 6 of one, .5doz of another. you are still moving the data.

>    When calling a PROGRAM (as opposed to a procedure) you MUST pass by
>    reference.   CONST is allowed, as that is still by reference.

define program:  it has a 'main'?

do you now prototype all of your new programs instead of using *entry
plists?

does that mean all of your other rpg and CL programs that call them use
callp instead of call?

>    When passing by either VALUE or CONST the compiler knows that you
>    will not be changing the variable, and therefore will automatically
>    insert code to convert from one variable type to another, or allow
>    you to use expressions, etc as appropriate.

elaborate on the phrase 'insert code to convert from one variable type to
another'.  I understand the using expressions part - but I assumed that the
expression would have to resolve to the same type of data as that the
parameter is expecting:

(%len(x)+1) would resolve to numeric data, (although i suppose the proc
could be expecting string and still be able to use this), and

(%trim(str1) + %trim(str2) would resolve to alpha, and unless there are
only numerics in the strings, couldn't be passed to a numeric parm.

is that what you mean by 'converting' variable types?  can you give me an
example of other types of variables that could be 'converted'? (pointer,
%addr(), date, binary, etc.)

> Hope that helps.

very much!

thanks,

Rick



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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

This mailing list archive is Copyright 1997-2026 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.