Hacker News new | ask | show | jobs
by vba616 1073 days ago
I don't remember much of Ada, but here's something very basic I liked (had to look the details up):

You could declare custom integer types like this:

type My_Type is range -5 .. 10;

And then you could reference the range with My_Type'First or My_Type'Last

And there were named parameters.

   for A in Range_Type loop
      I_IO.Put (
         Item  => A,
         Width => 3,
         Base  => 10);
      ...
   end loop;
1 comments

Nim [1] is like Ada in these ways but less verbose:

    import strutils # Or from strutils import repeat Or etc.
    type Foo = -5 .. 10                # Or range[-5 .. 10]
    echo Foo.low, " ", Foo.high        # range limits
    echo repeat(s = "x", n = Foo.high) # named params
    # var f: Foo = 15   # Will not compile
[1] https://nim-lang.org/