Re: C as a scripting language



Harald van Dijk wrote:
On Sun, 29 Mar 2009 13:45:30 -0600, Han from China wrote:
Richard Bos wrote:
Your implementation does not get to consider that, since the section on
<stdio.h> defines what output is, in the context of the C Standard.
Since the return value from main() does not go to a stream (at least
not within C), it is not output.
If that's the case, then it should be easy for you to quote that section
of the C Standard and show why a conforming C implementation isn't
allowed to consider the return status from main() as a form of output.

More precisely, it is the "termination status returned to the host environment", by either a call to exit() or by returning from the initial call to main(), which is a form of output. The return status from a non-initial call to main() is certainly not a output.

Do you want someone to go over each and every sentence in the standard and explain for each one how it doesn't support your idea of a return status as output? The only relevant thing I can find is 7.19.2p1, and I'm having trouble seeing how you could link return statuses to streams.

This question is being raised in the context of section 4p5, which does not restrict the 'output' to be stream output. The standard does not define 'output', leaving it to be interpreted in accordance with conventional English usage in the context of computer programming. The standard uses the word 'output' in at least one context where it clearly does not refer to stream output: footnote 116 refers to a "memory-mapped input/output port" (I didn't bother searching further after finding the first such example).

I cannot come up with any reasonable definition of the term 'output', consistent with the normal usage of English in the computer world, that includes both stream and port I/O, while failing to include the exit status of the program. This is all information generated by the program, and communicated outward from the program.

I've looked and found several definitions of 'output' that clearly exclude the exit status. However, those same definitions also exclude data written to a file, for precisely the same reason: for some of those definitions, the reason is that the data is not perceived by the user; for other definitions, it is because the data has not exited the computer system. In either case, the reason applies just as easily to the exit status as to data written to a file. I consider this a defect in those definitions. Taken literally, use of those definitions in the interpretation of section 4p5 implies that data written to a file has no effect upon whether or not a program is strictly conforming.
.



Relevant Pages

  • Re: C as a scripting language
    ... in the context of the C Standard. ... Since the return value from maindoes not go to a stream (at least ... trouble seeing how you could link return statuses to streams. ...
    (comp.lang.c)
  • Changes to OWS.JS do not appear
    ... I'm trying to follow the context menu changes specified here: ... but for some reason my changes don't appear - it just displays the ... 'standard' context menu. ... If there is a compile error in my Javascript file, ...
    (microsoft.public.sharepoint.portalserver.development)
  • Re: C as a scripting language
    ... Richard Bos wrote: ... in the context of the C Standard. ... Since the return value from maindoes not go to a stream (at least not ...
    (comp.lang.c)
  • Re: C as a scripting language
    ... in the context of the C Standard. ... Since the return value from maindoes not go to a stream (at least not ... Infinite reducibility... ...
    (comp.lang.c)
  • Re: Qry : Behaviour of fgets -- ?
    ... There is no such thing as a form of undefined behaviour because it ... definition in the C Standard. ... The reason for this is that it isn't wrong. ... Unfortunately, in this context, it's entirely wrong. ...
    (comp.std.c)