News for hackers. Stuff that matters.
Re:Giving Ada a Chance by FpUser on Tuesday March 02, 2021 @04:08PM (#26320773)

  type
    TPerson = record
      name: string;
      age: integer;
    end;
    TThrteenPersons = array[10..22] of TPerson;

  procedure Check(const aPerson: TPerson);
  var
    vPerson: TThrteenPersons;
  begin
    vPerson[11] := aPerson; // this is ok
    vPerson[1] := aPerson; // this one gives compile error
  end;
alternatively if runtime range checking is on then vPerson[i] = aPerson will raise the exception if i is out of range
Re:Giving Ada a Chance by Jtsummers on Tuesday March 02, 2021 @04:12PM (#26320831)
Right. I know it works with numeric indexes in Pascal. My point was that (using my previous example) in Ada it works with any discrete type, in that case characters (which are not numbers in disguise in Ada) so I can do this:

  Histogram : Character_Histogram;
  ...
  Histogram['A'] := Histogram['A'] + 1;
(Ok, a bit more work because I didn't initialize the histogram to 0.)
Re:Giving Ada a Chance by kwhitefoot on Tuesday March 02, 2021 @05:26PM (#26321929)
It works with any ordinal type in Pascal, including characters, booleans and enums.
Re:Giving Ada a Chance by Lucretia9 on Tuesday March 02, 2021 @04:56PM (#26321512)
Square brackets are coming, so you'd have to use ('A')
Re:Giving Ada a Chance by Jtsummers on Tuesday March 02, 2021 @05:40PM (#26322111)
Hah, I've been in Go lately so my brain defaulted to the wrong thing in that example.
Re:Giving Ada a Chance by FpUser on Tuesday March 02, 2021 @05:25PM (#26321910)
Pascal (well Delphi/FreePascal incarnation) also works with chars and enums.

This modern pascal is very feature rich and has plenty of fancy bells and whistles.

Re:Giving Ada a Chance by drfuchs on Tuesday March 02, 2021 @05:39PM (#26322106)
Wirth's original, standard Pascal allowed for int/char/bool/enum, and ranges thereof, as array bounds; it wasn't a Delphi enhancement.
Re:Giving Ada a Chance by FpUser on Tuesday March 02, 2021 @05:48PM (#26322204)
I am sure it was. I am just not familiar with it hence specified the one I know.