comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Ada.Command_Line.Argument_Count question
Date: Tue, 15 Sep 2009 14:55:25 -0700 (PDT)
Date: 2009-09-15T14:55:25-07:00	[thread overview]
Message-ID: <e3469b38-adca-4896-a5a6-4616db711914@i18g2000pro.googlegroups.com> (raw)
In-Reply-To: 4ab00009$0$282$14726298@news.sunsite.dk

On Sep 15, 1:58 pm, Thomas Løcke <"tl at ada-dk.org"> wrote:
> The RM has this to say about Argument_Count:
>
> "If the external execution environment supports passing arguments to a
> program, then Argument_Count returns the number of arguments passed to
> the program invoking the function. Otherwise it returns 0. The meaning
> of “number of arguments” is implementation defined."
>
> I'm wondering what that last sentence mean? Is the RM trying to tell me
> that Argument_Count cannot be trusted to yield the same result on
> different systems (Unix, BSD, Windows, Linux and so on)?

You can probably trust that Argument_Count will give the same result
on any Unix, BSD, Linux, or other Unix-like OS (Solaris, HP-UX, IRIX,
etc.), since the mechanisms that the shell uses for passing arguments
to programs is the same for all of them.  This is assuming the shells
handle the argument lines the same way.  Obviously, different shells
don't parse things the same way.  In fact, you have to be careful
about how you define "yield the same result"---yield the same result
under what conditions??  If you type the command

   application {file1,file2,file3}.dat

the argument count should be 3 if the shell interprets the curly
braces to convert the line to "file1.dat file2.dat file3.dat", but 1
if it doesn't (older Bourne shells don't).  So you could get a
different Argument_Count even on the *same* system, if you use the
same command line in a different shell.

Windows uses a totally different "shell" (Command Prompt) so you can't
expect it to work the same.  In practice, I don't believe Windows
breaks down the command line at all (maybe later versions do, I'm not
sure); it just makes the whole argument string available to the
program as one string (via GetCommandLine).  It's up to the
implementation to determine what to do with this string.


> Or am I missing the point?

Possibly.  The reason the meaning of "number of arguments" is
implementation-defined is that the language says nothing at all about
what an "argument" is or how it gets into the program.  The language
can't even assume that "arguments" will be passed in from a "command
line"; they could be passed in from separate boxes in a GUI window, or
created in an array by another program that executes the application,
or set up by rotating dials manually on a control panel for all we
know.

                               -- Adam




  parent reply	other threads:[~2009-09-15 21:55 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-15 20:58 Ada.Command_Line.Argument_Count question 
2009-09-15 21:37 ` Gautier write-only
2009-09-16  6:21   ` 
2009-09-16 18:43   ` Keith Thompson
2009-09-22 19:52     ` Gautier write-only
2009-09-22 20:00       ` Hyman Rosen
2009-09-23  0:20         ` Gautier write-only
2009-09-23  1:07           ` Adam Beneschan
2009-09-23 13:03             ` Hyman Rosen
2009-09-23 16:06             ` Gautier write-only
2009-09-24  0:31               ` Björn Persson
2009-09-24  1:11                 ` Adam Beneschan
2009-09-25 12:25                   ` Stephen Leake
2009-09-15 21:55 ` Adam Beneschan [this message]
2009-09-16  6:20   ` 
2009-09-16 10:41 ` Jeffrey R. Carter
2009-09-17 13:50 ` John McCabe
2009-09-18  5:12   ` sjw
2009-09-18 15:03     ` John McCabe
2009-09-18 22:16       ` Robert A Duff
2009-09-21 15:09         ` John McCabe
2009-09-21 15:17           ` Dmitry A. Kazakov
2009-09-21 19:44           ` sjw
2009-09-22 11:01             ` John McCabe
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox