From: Lawrence D'Oliveiro <ldo@nz.invalid>
Subject: Accessing The Command Line
Date: Thu, 4 Jul 2024 00:08:56 -0000 (UTC) [thread overview]
Message-ID: <v64p6n$2dviq$1@dont-email.me> (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.
next reply other threads:[~2024-07-04 0:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-04 0:08 Lawrence D'Oliveiro [this message]
2024-07-04 1:16 ` Accessing The Command Line 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
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox