Lawrence D'Oliveiro
2024-07-04 00:08:56 UTC
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.
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.