comp.lang.ada
 help / color / mirror / Atom feed
* Accessing The Command Line
@ 2024-07-04  0:08 Lawrence D'Oliveiro
  2024-07-04  1:16 ` Paul Rubin
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Lawrence D'Oliveiro @ 2024-07-04  0:08 UTC (permalink / raw)


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.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-07-05  8:58 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-04  0:08 Accessing The Command Line Lawrence D'Oliveiro
2024-07-04  1:16 ` Paul Rubin
2024-07-04  1:50   ` Lawrence D'Oliveiro
2024-07-04 15:13     ` Rod Kay
2024-07-04 16:15     ` Dmitry A. Kazakov
2024-07-04 11:27 ` Jeffrey R.Carter
2024-07-04 23:54   ` Lawrence D'Oliveiro
2024-07-05  8:58     ` J-P. Rosen
2024-07-04 13:01 ` Dmitry A. Kazakov
2024-07-04 19:42 ` Ben Bacarisse
2024-07-04 22:06   ` Paul Rubin

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