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


  • Subject: Re: Prototyping printf()
  • From: bmorris@xxxxxxxxxx
  • Date: Wed, 27 Sep 2000 13:30:08 -0400
  • Importance: Normal


>Date: Wed, 27 Sep 00 17:13:12 +1000
>From: "Simon Coulter" <shc@flybynight.com.au>
> ...
>I know C simplifies parameter passing by widening or promoting data types
but it still
>has to check the basic data type and handle it accordingly.  I see no real
reason why RPG
>couldn't do the same.  It just has more data types to handle so it has a
bigger case
>statement and it doesn't promote the data types.  The compiler knows how
much storage
>each declared variable occupies, it can't be too difficult to use that
information when
>building the argument list.  The only real difficulty is in deciding
whether the
>arguments occupy contiguous storage or not -- and to support the va_
macros used by
>printf() it should be contiguous.
> ...

Simon, the problem is that RPG has too many different numeric types.  What
should it pass for say 3.5?  RPG could adopt C's rules and only have 2
basic numeric type (integer and double-float), so 3.5 would be passed as
8F.  Or it could say that 3.5 was packed(2,1), or perhaps packed(15,5), or
maybe packed(30,15).  Once the compiler has figured out what the passed
type should be, you're right: it's easy.

By the way, for those who would like to venture into the va_list territory,
it IS possible to call vprintf and vsprintf with a single argument list
(Jim Langston, I don't think it's possible to call printf this way though).
But coding a va_list correctly is extremely difficult in RPG.  (*Much*
worse than doing the formatting yourself using RPG's own capability.)

>>Perhaps someday, ILE will have "externally-described" procedures, and RPG

>Isn't that what EXTPGM accomplishes anyway?  Or did you have something
else in mind?

What I have in mind is the ability for a compiler to extract "prototype"
information from a module or service program, similar to the way Java can
extract information directly from a compiled class.  Just a dream ...

Barbara Morris


+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---

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