× 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.



I second Mark's idea. It's true, we rarely read them although sometimes when trying to get a program to compile they make for interesting reading. Look at the warning you get for EVAL-CORR, for example. In my case I'd have just gone straight to the compile listing to check that my CONST/VALUE parameters were ok.

I am wondering what the point is of using CONST in our case. It does not signify that the parameter can never be modified as already discussed on this list. It only prevents the programmer from modifying it directly, as if that would happen in any reasonable situation. I always thought that declaring CONST was to indicate that this is an input only parameter passed by reference. What it actually means is <this is a parameter INTENDED for input only and watch out - it might be the wrong size >. 90% per cent of the time the parameters passed match perfectly. In the 10% of other cases, what does it cost to create a local variable and to pass that? That way the programmer writing the callp sees both the original (9,2) and the passed (9,0) parameter. The other programmers in our shop do not realize that by declaring CONST, they are saying to the compiler 'modify my parameter as you think fits'. I will be passing on what I have learned.



-----Message d'origine-----
De : rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] De la part de Rory Hewitt
Envoyé : samedi 15 mai 2010 06:14
À : RPG programming on the IBM i / System i
Objet : Re: Parameter prototype question

Mark,

No-one ever looks at compiler warnings. If it compiles, it's
good to go :) Seriously, do you ever look at those severity
10 warnings? I guess it could be a compiler option, but
surely it would have to flag every instance where a user
tries to pass a big field (perhaps at runtime with a validly low
value) to a small parameter? If so, then there could just be
so many of them, it would be pointless - I would certainly
ignore them.

Barbara,

You're right of course, but if the problem occurs when the
compiler attempts to copy the value to a temporary 5P 0
field, the error is less 'obvious'
isn't it? didn't the OP say something about not being able to
see why the procedure wasn't being called - he was stepping
through and the procedure "wasn't being called" or something
like that? At least with an explicit copy, the error is
pretty obvious and easy to debug.

Mind you, I use CONST or VALUE and check my code up-front :)

Rory

On Fri, May 14, 2010 at 6:35 PM, Mark S. Waterbury
<mark.s.waterbury@xxxxxxx
wrote:

Hi, Barbara:

Given this whole set of problematic scenarios, would it
perhaps not be
an improvement to have perhaps a new option on the compile
commands to
allow the RPG IV compiler to at least flag these situations with a
WARNING message? Then, at least the programmer could look at those
warnings and perhaps take preventive / corrective action
accordingly.

Mark S. Waterbury

> On 5/14/2010 8:24 PM, Barbara Morris wrote:
Rory Hewitt wrote:

...
However, if you *don't* have CONST specified, you always have to
move
the
value from the 10P 0 field into a 5P 0 work field to pass it to
the procedure. Since that process (before you've even called the
procedure)
will
stop you from passing a value that's> 99999, then the procedure
call
itself
will never fail. ...

It's true that the procedure call won't fail, but you've just
shifted the problem to the assignment statement where you set up
your 5P
variable.

If the 10P variable has a value bigger than 99999, you
will get an
exception no matter how you try to pass it to a 5P
parameter. The
exception will happen either when you copy it to your own 5P
variable to satisfy the non-CONST parameter, or when the compiler
copies it to its 5P temporary for the CONST parameter.

So you not only have to manually verify every CONST or VALUE
parameter, you also have to manually verify every
assignment. Or,
to put it another way, if for some reason you don't need
to manually
verify every assignment, you shouldn't need to verify CONST and
VALUE parameters
either.

--
This is the RPG programming on the IBM i / System i
(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.




--

Rory Hewitt

http://www.linkedin.com/in/roryhewitt
--
This is the RPG programming on the IBM i / System i
(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 thread ...

Follow-Ups:
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.