From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,6e64435d2a7280f2 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,CP1252 Path: g2news2.google.com!postnews.google.com!i18g2000pro.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Ada.Command_Line.Argument_Count question Date: Tue, 15 Sep 2009 14:55:25 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <4ab00009$0$282$14726298@news.sunsite.dk> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1253051725 14501 127.0.0.1 (15 Sep 2009 21:55:25 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 15 Sep 2009 21:55:25 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: i18g2000pro.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618),gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:8336 Date: 2009-09-15T14:55:25-07:00 List-Id: On Sep 15, 1:58=A0pm, Thomas L=F8cke <"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 =93number of arguments=94 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