[net.lang.c] Command line arguments

woody%Juliet.Caltech.Edu@cit-hamlet.ARPA (03/03/86)

>   [ Wayne Throop ]
>>  [ Carl Kuck ]

>>  2.  Command-line arguments are a part of C.
>>      Ref: K&R, chapter 5.11
>
>   Again, you don't catch on to subtleties.  The phrase is
>   "command-line arguments *or* parameters.  In fact, careful reading of
>   K&R convinces me that C may be correctly implemented on systems that
>   (shudder) *have* *no* *commands* *or* *command* *lines*, let alone
>   "command-line arguments."

    Like the Macintosh, where (despite Apple Computers) C seems to be the
de-facto programming language.  Under the Finder (read: Shell), running a 
program is done by double-clicking the icon representing the program with
the mouse, and arguments may be passed by shift-clicking the appropriate
file icons before double-clicking the program icon.  Command lines?  What
command lines?  Do you see any command lines?

         - William Woody
      NET  Woody%Romeo@Hamlet.Caltech.Edu
   USNAIL  1-54 Lloyd, Caltech / Pasadena, CA 91126

simon@simon_pc.UUCP (Simon Shapiro) (03/04/86)

All this arguing about what did K&R mean here or there reminds me of
a Talmud study, with one exception.  The Rabi is still alive!
Maybe Mr. Ritchie can tell us what he ment when he said what he said
about what he said (Command line argument passing) instead of all
this (very amusing) argument about arguments?

I refer this to Mr. Dennis Ritchie and not to Mr. Brian Kernigham only
because I saw a recent postig by the first (so he must be listening to
all of this) but did not catch the later's name on this network.

Simon.

david@ztivax.UUCP (03/05/86)

Modern Arguments to main()

>[W.Woody]
>    Like the Macintosh, where (despite Apple Computers) C seems to be the
>de-facto programming language.  Under the Finder (read: Shell), running a 
>program is done by double-clicking the icon representing the program with
>the mouse, and arguments may be passed by shift-clicking the appropriate
>file icons before double-clicking the program icon.  Command lines?  What
>command lines?  Do you see any command lines?

THIS IS A GOOD POINT!!

I am currently porting UNIX fuctionality (nee filter tools, cmd
interpreter) onto a really nice user interface.  This things got
windows and mouse, all that stuff, but more:

You can point at stuff (text in a file, program names, icons, etc)
and use it as stdin/out.  Right now these capabilities are only
available in the systems own one-off programming language.  Soon,
it will be available in C.

WHAT I NEED IS YOUR IDEAS:

Who has good ideas on a C standard which would allow "command line
arguments" to be expanded to include nicer things, like text from
anywhere (within a file, db, ...), or like ????

Should this be left to the "shell" or window manager (or finder
or ... ) ??  Perhaps, but remember, one of the things which makes C
tools so easy to write is that the interface main(argc,argv) is so
intuitive for someone working within a command line oriented world.
If the world is not command line oriented, but icon oriented, the
mapping is no longer intuitive, and perhaps the further development of
simple tools will be thwarted...

mail or respond, at your option...

David E. Smyth
Cubitech Corporation

seismo!unido!ztivax!david

peter@baylor.UUCP (03/07/86)

>     Like the Macintosh, where (despite Apple Computers) C seems to be the
> de-facto programming language.  Under the Finder (read: Shell), running a 
> program is done by double-clicking the icon representing the program with
> the mouse, and arguments may be passed by shift-clicking the appropriate
> file icons before double-clicking the program icon.  Command lines?  What
> command lines?  Do you see any command lines?

Yes. The "command line" is the list of files involved, and a good
implementation of 'C' will have the run_time library load up argv
with the values before calling main(). Are there any such things?
-- 
-- Peter da Silva
-- UUCP: ...!shell!{baylor,graffiti}!peter; MCI: PDASILVA; CIS: 70216,1076

gwyn@brl-smoke.UUCP (03/09/86)

There have been articles recently pointing out that there is no
"command line" in an icon-driven environment.  I believe some of
the articles have missed the point about argv (which was the
original topic of discussion).  According to X3J11, there are
two possible conforming C environments:  "hosted", which must be
able to provide program arguments (NOT repeat NOT "command line"
arguments) and receive exit status, and "free-standing", which
need not even have a main() function, let alone program
arguments.

It is of course possible to implement C in an icon-oriented
environment as a "free-standing" implementation.  Generally,
one will need special library routines to access data objects
anyway in such an environment, so transportability is not a big
issue in this case.  Process interface characteristics will
depend on the specific operating environment in a non-portable
way.

Another possibility is to provide a "hosted" implementation in
the icon-oriented environment.  In this case, there must be an
automatic mapping of icon-selected entities into character
strings for the argv array supplied to main().  This may or may
not fit into existing icon interface schemes.  All this means
is that it may not be possible to advertise a conforming
"hosted" implementation of C in such an environment.  I see no
problem with that; if the UNIX-like software tool model doesn't
fit, don't use it.

If you're going to write programs for an object-oriented
environment, how about using an object-oriented programming
language rather than C.  Better yet, how about generalizing
a la Alan Kay to an agent-oriented environment with an
appropriate user interface.  Other than for implementing the
environment itself, one might then be able to do without
"programming languages" altogether.

woody%Juliet.Caltech.Edu@cit-hamlet.ARPA (03/09/86)

	For those who may be interested in such things as Icon-driven 
environments, this is what the Macintosh computer does under the Macintosh
Megamax C compiler:  (other implementations may vary)
	When you double click a program icon, the file name of the program
gets passed to the C program through argc/argv; when you shift click some
documents before double clicking a program icon (thereby telling the program
to use those documents), the names of the documents get passed to the
C program through argc/argv--one document name for every element in argv[].
And when you shift click some documents, select a program, and select
the "Print" option from one of the Finder (read: Macintosh shell) menus,
the argument "-p" gets passed to the C program in argv[].

	So, the Macintosh does support passing arguments to the program;
however, it's not as flexible as a command line entry under the Unix shell
where command line arguments may be just about any arbitrary string.

         - William Woody
      NET  Woody%Romeo@Hamlet.Caltech.Edu
   USNAIL  1-54 Lloyd, Caltech / Pasadena, CA 91126