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=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!spool.mu.edu!news.cs.indiana.edu!arizona.edu!east.pima.edu!rharwood From: rharwood@east.pima.edu Newsgroups: comp.lang.ada Subject: Re: Command line arguments Message-ID: <1991Apr29.224029.1@east.pima.edu> Date: 30 Apr 91 05:40:29 GMT Article-I.D.: east.1991Apr29.224029.1 References: <91113.165139TAINT021@ysub.ysu.edu> <1991Apr25.143711.11311@ecst.csuchico.edu> <3275@enea.se> List-Id: In article <3275@enea.se>, sommar@enea.se (Erland Sommarskog) writes: > Undoubtedly it would be pleasant if all Ada compilers on > Unix were interchangeable on argv/argc, but that something > like a POSIX binding not Ada 9X. > > Since you retrieve the arguments differently in different OSs, > reading the command line is something which by definition is > not portable(*) so it can't be in the language. Remember that > the command-line interface itself is OS dependent. > > (*) Yes, I know that argc/argv is commonly available with C > implementations. But if you're going to get the command-line > interface right in, say, VMS, you better use the CLI$ routines. Erland, I agree 100%. Here's perhaps some more "justification". Perhaps the "correct" way for portability would be to write a package for EACH PROGRAM (or system) that has functions which return the possible values of switches and other command line "entries", like the following parameters for a PC-based file DUMP routine I recently wrote: type bases is (hex, ascii, octal); function address_format return bases; function file_to_dump return string; Then your "main" routine calls these functions, no matter what the external environment is. NOW comes the "non-portable" interface, where the actual BODIES of those functions above must call the OS-specific routines to determine the command line arguments. It would conceptually be possible to write two external interface routines: (1) one which works under the "unit test" mode and runs on the "host" system such as the VAX or PC-compatible (2) another which runs only on the target hardware, perhaps an embedded 80186 or 1750A machine. Ada is NOT the first language where information hiding has advantages... We must THINK in terms of portability and encapsulation during DESIGN. At CODE time is too late! <"plop-plop"... stepping of off soap box> Ray ----- Ray Harwood |Data Basix |Associate Faculty, Voice: (602)721-1988 |PO Box 18324 | Pima Community College FAX: (602)721-7240 |Tucson, AZ 85731 |Instructor in Ada and Pascal CompuServe: 76645,1370|AppleLink: DATA.BASIX|Internet: rharwood@east.pima.edu