Deutsch   English   Français   Italiano  
<v64p6n$2dviq$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Lawrence D'Oliveiro <ldo@nz.invalid>
Newsgroups: comp.lang.ada
Subject: Accessing The Command Line
Date: Thu, 4 Jul 2024 00:08:56 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <v64p6n$2dviq$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 04 Jul 2024 02:08:56 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="c455704f93161f76beb27198f91da8a6";
	logging-data="2555482"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18fX3u6klEnK/H0Bdoy15xk"
User-Agent: Pan/0.158 (Avdiivka; )
Cancel-Lock: sha1:8NzYNcgOCP62q/dbl82xDZN1wds=
Bytes: 2194

with Ada.Command_Line;
with Ada.Text_IO;

procedure Echo is

    package cli renames Ada.Command_Line;
    package tio renames Ada.Text_IO;
    package int_io is new tio.Integer_IO(Num => Integer);

begin
    tio.put("my name: ");
    tio.put(cli.Command_name);
    tio.Put_Line("");
    tio.Put("nr args: ");
    int_io.Put(cli.Argument_Count, width => 1);
    tio.Put_Line("");
    for i in 1 .. cli.Argument_Count loop
        tio.put("[");
        int_io.put(i, width => 1);
        tio.put("]: ");
        tio.put(cli.argument(i));
        tio.put_line("");
    end loop;
end Echo;

----

Comments:

Ada, like Python, offers the convenience of being able to specify
local “nicknames” for imported packages, to save some typing.

Having become used to the convenience of printf-style formatting in C
and other languages that have adopted it (including Lisp and Python),
I don’t miss the tedium of having to format and output one item at a
time. Though I recognize that there is no way to do printf style in a
type-safe fashion, short of going to a fully-dynamic language.

Being able to access the POSIX command line via some globally-defined
entity instead of arguments to a “mainline” procedure is something
that just about every decent language offers. C is notably absent from
this list.