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




On 26/10/2009, at 11:31 PM, Dennis Lovelady wrote:

I disagree about the implication. From the function's perspective,
arguments are received; return values are passed.

From the caller's perspective parameters are passed and return values received :) so your point is ...?


If that's true then because RPG's default behaviour is to presume no
widening then I should be able to specify no widening in the C

Are you sure we can call this "RPG's default behavior," Simon? If it were,
wouldn't the change from default require coding something like *CWIDEN,
rather than the opposite?

RPG doesn't do any widening. You have to tell it to widen by use of *CWIDEN. I think the only reason *CNOWIDEN exists is to tell RPG to deal with C's peculiar return mechanism. It's not necessary if #pragma argument (fn, nowiden) is specified in the C code. You can see that no widening occurs by a simple test (or by reading my original append and seeing how RPG gets the leading X'00' from the C return value).


This supports my presumption that C always widens the return value so
I wonder what happens if I remove #pragma nowiden from the C function
and tell RPG that *CNOWIDEN is actually in effect. I make those
changes and now when I run the program I see compileFlags contains
X'75'. Curiouser and curiouser.

My assumption has always been that under the covers the binding process is
aware of the language types of the caller and called functions. Certain
"conversions" may be done in order to make the languages with different
attributes play well together.

Based on previous discussions I'm fairly sure that after compilation language differences disappear and are not visible or known to the later steps (e.g., bind or run). I think there is special support for CALL from command line to a C program (i.e., null-termination of literals) but that's all. For inter-language calls the expectation is that the caller passes the right stuff.


One who is brought up in the C world rather than the RPG world might argue
that RPG is completely ridiculous in its approaches that differ from C.

Except that it is only C and it's derivatives (including interpretive languages based on C) that adopt these peculiarities. RPG, COBOL, PL/1 and a bunch of other unrelated languages all behave more like each other than not. C is singularly the odd one out. Granted that if you started with C and have little exposure to other languages then many "normal" things (like fixed length character variables, decimal data types, bidirectional parameter passing, a proper inter-program call mechanism, a compiler that actually does things for you instead of the bare minimum thus requiring various lint checkers to get "good" code, etc. etc.) might seem ridiculous but that is really edging toward the endless language wars which I'd rather not continue.

For
example, the length attribute rather than a null-terminated string. That's
so IBM!

Including Pascal and it's derivatives so perhaps not "so IBM". Besides, surely it makes much more sense to consume 2 bytes to hold the current length than constantly having to scan for a magic end-of- string marker? I've been told that C only does it that way because it was developed on PDP hardware which had an efficient machine instruction for doing exactly that. Thus 40 years later we are still hamstrung by implementation decisions made with little foresight-- although I do have the advantage of hindsight when I say that.

But it is what it is, and we have to take the things we don't like
along with those that we consider cool.

Ah, but nothing about C is cool--it's an appalling language for almost any task.

On the other hand, if they all worked alike, there'd be only one, right?


That's true! There can be only one ...

However, you have not addressed any of the questions in my original append. Do you have any information regarding those?

Midnight here so off to bed for me.

Regards,
Simon Coulter.
--------------------------------------------------------------------
FlyByNight Software OS/400, i5/OS Technical Specialists

http://www.flybynight.com.au/
Phone: +61 2 6657 8251 Mobile: +61 0411 091 400 /"\
Fax: +61 2 6657 8251 \ /
X
ASCII Ribbon campaign against HTML E-Mail / \
--------------------------------------------------------------------




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.