× 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: "Simon Coulter" <shc@xxxxxxxxxxxxxxxxx>
  • Date: Wed, 27 Sep 00 17:13:12 +1000
  • Importance: Normal

h
Hello Barbara,

You wrote:
>C can support the ellipsis because it has only has 3 basic types: int,
>double, pointer.  No matter what it sees as a parameter, it knows what
>to actually put on the parameter stack (*usually* what the programmer
>intended.  'a' gets passed as a 4-byte int, 1.3 gets passed as a double,
>"abcde" gets passed as a pointer.  The problem is that RPG has many
>more basic types than RPG does.

I don't see more data types as being the root of the problem.  Variables are 
simply 
n-bytes at x-address regardless of the type (pointers are 16, ints are 2 or 4, 
floats are 
4 or 8, etc.).  The problem is that prototypes requires a data type.  

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. 

        ---- useful example code deleted ------

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

>will have good support for variable-typed parameters.  I don't think
>printf and its dot-dot-dot friends are a good model for this, though.

Perhaps not, but it seems there is sufficient interest in such a facility (even 
with the 
simple syntax I described earlier) for it to move up the ToDo list.  Now how 
WILL I spend 
my $100 ....

Regards,
Simon Coulter.

«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»
«» FlyByNight Software         AS/400 Technical Specialists       «»
«» Eclipse the competition - run your business on an IBM AS/400.  «»
«»                                                                «»
«» Phone: +61 3 9419 0175      Mobile: +61 0411 091 400           «»
«» Fax:   +61 3 9419 0175      mailto: shc@flybynight.com.au      «»
«»                                                                «»
«» Windoze should not be open at Warp speed.                      «»
«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»
+---
| 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 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.