I would prefer the mismatch be caught at compilation time opposed to
runtime...head 'em off at the pass...
Thanks,
Tommy Holden
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[
mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Bruce Vining
Sent: Monday, May 07, 2007 4:17 PM
To: RPG programming on the AS400 / iSeries
Subject: Re: Another ILE question : CONST vs VALUE
Nor is there any run-time mechanism to detect the mis-match.
I do not know if RPG takes advantage of this (and suspect it doesn't,
but
Barbara would know for sure), but the system can provide some basic
run-time checking. If the caller specified that a parameter was to be
treated as a constant, then the storage for the parameter could (and I
emphasize could) be carved out of a read-only memory allocation by the
compiler/run-time. Attempts to modify the constant by the called
program
would then be detected.
A minor point, but the system could provide some checking in this area
(though it is dependent on the compiler).
Bruce Vining
Ken Sims <mdrg6315@xxxxxxxxxxx>
Sent by: rpg400-l-bounces@xxxxxxxxxxxx
05/07/2007 03:37 PM
Please respond to
RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx>
To
rpg400-l@xxxxxxxxxxxx
cc
Subject
Re: Another ILE question : CONST vs VALUE
Hi Bob -
On Mon, 7 May 2007 13:16:08 -0500, "Bob Cozzi" <bob@xxxxxxxxxxxx>
wrote:
CONST parms can't be changed by the called subprocedure, unless as Joe
explained
there is some subversion going on. But even then, if I recall
correctly,
there
is in fact a runtime error that will occur if you pull the address-of
the
const
and try to modify it. OS/400 pointers are very secure.
That's true only if the subprocedure is compiled with CONST on the PI.
If the subprocedure is compiled using a PR and PI without CONST, there
are no restrictions on changing the parameter because the compiler has
no way to know that the caller will be using a prototype with CONST.
Nor is there any run-time mechanism to detect the mis-match.
The stack thing is all academic--it doesn't really occur that way on
real
computers like System i. Sure its simulated but at the end of the day,
just a
pointer is passed by reference, not the value. Sure some things are put
into
registers, but even VALUE parameters are passed by reference under the
covers.
(Correctly if I'm wrong about this; if I am, I'm sure someone will.)
You're wrong about this. Parameters passed with VALUE have the actual
parameter placed in the call parameter list where a pointer would be
placed for a parameter passed by reference.
Ken
http://www.kensims.net/
Opinions expressed are my own and do not necessarily represent the views
of my employer or anyone in their right mind.
As an Amazon Associate we earn from qualifying purchases.