Command line arguments, redirection, etc.

throopw at dg_rtp.UUCP throopw at dg_rtp.UUCP
Mon Feb 24 11:38:35 AEST 1986


[   Warning.  Some of my comentary below contains (gasp) Humorous
    Content.  In no way should the Mild Humor in this posting be
    confused with Hurtful and Counterproductive Sarcasm.
    You have been Warned!  ]

>   Hopefully, this "discussion" about argument passing, redirection, and
> such can be put to rest once and for all.

Close, but no cigar.

> 1. Redirection of standard I/O is a part of C, piping is not.
>    Ref: K&R, chapter 7
>
>    "Finally, the routines are meant to be 'portable', in the sense that
>     they will exist *in compatible form* on any system where C exists"...
>
>    The routines mentioned are those which use "standard I/O".  See page
>    144... "output can be redirected to a file by using >...", and "On
>    the UNIX system, a pipe can also be used..."  This implies that
>    redirection is required functionality, whereas piping is a part of
>    a particular operating system.

Well, your heart's in the right place, you *do* got religion, but I
don't think you've really imersed yourself in the Holy Texts.  In
particular, you missed the fact that on page 143, to introduce the whole
chapter on IO, The Book says

        And DMR created Facilities, Input and Output created He Them,
        And these Facilities were separate from The Language of C,

Oops, sorry, that was the King James version.
Let me get my Modern Reformed copy...

        Input and output facilities are not part of the C language,

Now, you can dismiss this by saying that in common usage the phrase "the
C language" refers to both the formal language definition *and* the
supporting libraries (at least stdio).  But worse yet (you heretic you),
you missed the quote just above the one you took from page 144:

        In most environments that support C, a file may be substituted
        for the terminal by using the < convention

In particular, The Book says "most" (not "all") environments that
support C, so it is *not* a requirement, merely a coincidence.  So, even
if one takes the standard IO libraries to be "part of the language", C
doesn't require "<>" style redirection any more than it requires the "|"
piping convention.

> 2. Command-line arguments are a part of C.
>    Ref: K&R, chapter 5.11
>
>    "In environments that support C, there is a way to pass command-line
>     arguments or parameters to a program when it begins executing."

Again, you don't catch on to the subtleties.  The phrase is
"command-line arguments *or* parameters".  In fact, careful reading of
K&R convinces me that C can be correctly implemented on systems that
(shudder) *have* *no* *commands* *or* *command* *lines*, let alone
"command-line arguments".  All that is nailed down is some way to pass
text string parameters to programs at execution time.  The method isn't
spelled out, and in particular it needen't be "commands" which have
"arguments".

> It sounds to me like this whole issue boils down to whether or not someone
> has taken the time to *correctly* implement C to provide the functionality
> as specified in K&R (or whatever else happens to be your favorite standard).

I guess I agree with that.

> [ Personal opinion, FLAME ON ]
>
> Any implementation of C that doesn't provide redirection and command-line
> argument passing is half-assed at best.
>
> [ FLAME OFF]

It may be half-assed, but it could still be a legal C implementation.

> You know, I feel better already!  Hey kiddies, get out YOUR copy of K&R and
> read, read, read!   

Good idea.  Try Harbison and Steele also.

> -- Carl Kuck (apply all standard disclaimers to the preceeding babble)

--
(Gee, isn't being a language lawyer fun?  Just think what can be done
 with interpreting ANSI C when it comes out!  Can you say "job security"?
 I knew you could...)
-- 
Wayne Throop at Data General, RTP, NC
<the-known-world>!mcnc!rti-sel!dg_rtp!throopw



More information about the Comp.lang.c mailing list