[Info-vax] Rust as a HS language, was: Re: Quiet?

Arne Vajhøj arne at vajhoej.dk
Fri Apr 8 13:13:14 EDT 2022


On 4/7/2022 2:46 PM, Dan Cross wrote:
> In article <t2navi$sdf$2 at dont-email.me>,
> Simon Clubley  <clubley at remove_me.eisner.decus.org-Earth.UFP> wrote:
>> BTW, I wouldn't mind seeing Ada's ranged integers showing up elsewhere,
>> including being supported as an array index. That's a very nice feature
>> of Ada.
> 
> That's a feature I would very much like to have.

Pascal has it.

:-)

$ type ar.pas
program ar(input,output);

type
    r = 1..3;
    a = array[r] of integer;

var
    v : a;
    i : r;

begin
    for i := 1 to 3 do begin
       v[i] := 10 * i;
    end;
    writeln(v[1], ' ', v[2], ' ', v[3])
end.
$ pas ar
$ link ar
$ run ar
         10         20         30

Well - Pascal has the declaration and usage part - it is
not as type safe as Ada. In Ada terminology r is a subtype
not a type.

$ type ar2.pas
program ar2(input,output);

type
    r = 1..3;
    a = array[r] of integer;

var
    v : a;
    i : r;

begin
    for i := 1 to 3 do begin
       v[i] := 10 * i;
    end;
    i := 4;
    v[i] := 40;
    writeln(v[1], ' ', v[2], ' ', v[3], ' ', v[4])
end.
$ pas ar2
$ link ar2
$ run ar2
%PAS-F-ARRINDVAL, array index value is out of range
%TRACE-F-TRACEBACK, symbolic stack dump follows
   image    module    routine             line      rel PC           abs PC
  ar2  AR2  AR2                             16 000000000000002C 
000000000002002C
                                             0 FFFFFFFF80340964 
FFFFFFFF80340964
%TRACE-I-END, end of TRACE stack dump
$ pas/check=sub ar2
$ link ar2
$ run ar2
%PAS-F-SUBASGVAL, subrange assignment value is out of range
%TRACE-F-TRACEBACK, symbolic stack dump follows
   image    module    routine             line      rel PC           abs PC
  ar2  AR2  AR2                             15 000000000000002C 
000000000002002C
                                             0 FFFFFFFF80340964 
FFFFFFFF80340964
%TRACE-I-END, end of TRACE stack dump

Arne




More information about the Info-vax mailing list