Re: Why you shouldn't be afraid to use VARCHAR in RPGLE

Javier Sanchez <[email protected]>
Newsgroups gmane.comp.lang.as400.rpg
Message-ID <CAAvhgxLmohaKz9M=a0B1kjy-66aAAx0y3-u=gt5fCVpZhqkFGQ@mail.gmail.com>
Paul,

"C" has it as a native language for over decades.  Can't see why that would
be complex for them to follow and make it available for devs.
Of course, and WADR, you need to "know what you are doing" with your return
value.  That is kind of your intellectual work.
Efficiency and cleanliness of code is vital for modern languages. Elegant
code is, and simplicity is a major goal in our era.

JS

El jue, 11 dic 2025 a las 9:50, Paul Therrien via RPG400-L (<
[email protected]>) escribió:

> Not knowing 'C' I asked Google.
>
> Google AI says this:
>
> The statement boolVal = (a = b ? 0: 1) in C is a syntactically valid but
> potentially confusing use of the ternary operator and assignment operator
> within a single expression [1].
>
> What it does
> Essentially, the line of code is a verbose way of setting boolVal based on
> whether b is zero or not, while simultaneously changing the value of a:
> If b is 0: a becomes 1, and boolVal becomes 1.
> If b is non-zero: a becomes 0, and boolVal becomes 0.
>
> I think I can see why IBM might not be in a hurry to handle this request.
>
> -----Original Message-----
> From: RPG400-L <[email protected]> On Behalf Of Javier
> Sanchez
> Sent: Thursday, December 11, 2025 10:12 AM
> To: RPG programming on IBM i <[email protected]>
> Subject: Re: Why you shouldn't be afraid to use VARCHAR in RPGLE
>
> Vern,
> I believe I saw this once already posted, not sure, but if necessary, I
> will put it in as an IBM Ideas item.
> On the side of IBM, this could be something rather obvious, and probably
> not wait to have it submitted, WADR.
> JS
>
> El jue, 11 dic 2025 a las 9:04, Vern Hamberg via RPG400-L (<
> [email protected]>) escribió:
>
> > Javier
> >
> > Have you submitted this as an Idea? IBM do listen to us, and I'm very
> > impressed about that.
> >
> > *Regards*
> >
> > *Vern Hamberg*
> >
> > IBM Champion 2025 <cid:[email protected]> CAAC
> > (COMMON Americas Advisory Council) IBM Influencer 2023
> >
> >
> > On 12/11/2025 8:14 AM, Javier Sanchez wrote:
> > > Thanks Barbara.  Nothing better than explanations coming from the
> > creators
> > > of the compiler.  Of course you guys know what all that means and
> > > your contributions will always be appreciated.
> > >
> > > BTW, I have wondered a lot why you guys have not yet implemented the
> > C-like
> > > expression as:
> > > boolVal = (a = b ? 0: 1);
> > > This is not only necessary for modern RPG but it should have been
> > provided
> > > long time ago! :-)
> > > JS
> > >
> > > El mié, 10 dic 2025 a las 22:04, Barbara Morris
> > > (<[email protected]>)
> > > escribió:
> > >
> > >> On 2025-12-10 12:25 p.m., James H. H. Lampert via RPG400-L wrote:
> > >>> On 12/10/25 4:06 AM, Infodorado InfoDorado via RPG400-L wrote:
> > >>>> The RPG compiler is a single-pass compiler
> > >>> No, it can't be pure single-pass. If it were, then a program in
> > >>> which a variable is NOT defined in a D-spec, nor in the first
> > >>> C-spec in which
> > it
> > >>> appears, would not compile, much less run. And it's trivially
> > >>> simple to construct an example of this (it took me about 2
> > >>> minutes), and it compiles and runs just fine. I'd quote the source
> > >>> here, but it would likely be mangled beyond recognition.
> > >>>
> > >> It's a single pass through the source but it gathers information
> > >> that it can use multiple times.
> > >>
> > >> The compiler usually allows forward-referencing, so you can code
> > >> LIKE(x) where x is defined later.
> > >>
> > >> But for free-form definitions, the compiler requires the parameter
> > >> for the data-type keywords to be defined before the keyword is seen.
> > >>
> > >>      dcl-s x char(con1);  // bad, con1 not defined yet
> > >>      dcl-c con1 5;
> > >>      dcl-s y char(con1);  // ok, con1 is defined
> > >>
> > >> Where it becomes extra fun is when you have a data structure that
> > >> LOOKS defined.
> > >>
> > >>      dcl-ds ds1;
> > >>         subf char(10);
> > >>      end-ds;
> > >>      dcl-s x char(%size(ds1));  // %size(ds1) is not defined. WHAT???
> > >>
> > >> RPG allows you to define the length of a data structure later,
> > >> either due to being on an I spec, possible an externally-described
> > >> I spec, or on a C spec.
> > >>
> > >>        C            MOVE    *blanks       ds1        50
> > >>
> > >> Almost certainly wrong columns, but you get what I mean. I'm
> > >> defining
> > >> DS1 to have a length of 50 here, not the length of 10 that it
> > >> looked like it should have. Shenanigans? Yep, but upward-compatible R
> Us.
> > >>
> > >> We have a H-spec/CTL-OPT keyword for that: DLCOPT(*NOCHGDSLEN).
> > >> With that keyword, the compiler doesn't allow you to change the
> > >> length of the data structure like that, so it's considered defined
> > >> as soon as all the subfields are defined.
> > >>
> > >> --
> > >> Barbara
> > >>
> > >> --
> > >> This is the RPG programming on IBM i (RPG400-L) mailing list To
> > >> post a message email:[email protected] To subscribe,
> > >> unsubscribe, or change list options,
> > >> visit:https://url.us.m.mimecastprotect.com/s/ZWScCwpEpkTGRwrNHVfLFJ
> > >> obq7?domain=lists.midrange.com or
> > >> email:[email protected]
> > >> Before posting, please take a moment to review the archives
> > >> athttps://archive.midrange.com/rpg400-l.
> > >>
> > >> Please [email protected] for any subscription
> > >> related questions.
> > >>
> > >>
> > --
> > This is the RPG programming on IBM i (RPG400-L) mailing list To post a
> > message email: [email protected] To subscribe, unsubscribe,
> > or change list options,
> > visit:
> > https://lists.midrange.com/mailman/listinfo/rpg400-l
> > in=lists.midrange.com or email: [email protected]
> > Before posting, please take a moment to review the archives at
> > https://archive.midrange.com/rpg400-l.
> >
> > Please contact [email protected] for any subscription
> > related questions.
> >
> >
> --
> This is the RPG programming on IBM i (RPG400-L) mailing list To post a
> message email: [email protected] To subscribe, unsubscribe, or
> change list options,
> visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
> or email: [email protected]
> Before posting, please take a moment to review the archives at
> https://archive.midrange.com/rpg400-l.
>
> Please contact [email protected] for any subscription related
> questions.
>
>
> --
> This is the RPG programming on IBM i (RPG400-L) mailing list
> To post a message email: [email protected]
> To subscribe, unsubscribe, or change list options,
> visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
> or email: [email protected]
> Before posting, please take a moment to review the archives
> at https://archive.midrange.com/rpg400-l.
>
> Please contact [email protected] for any subscription related
> questions.
>
>
-- 
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: [email protected]
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: [email protected]
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact [email protected] for any subscription related questions.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.