From: arne@vajhoej.dk   
      
   On 9/6/2025 3:09 PM, Waldek Hebisch wrote:   
   > Arne Vajhøj wrote:   
   >> On 9/5/2025 9:50 PM, Waldek Hebisch wrote:   
   >>> Arne Vajhøj wrote:   
   >>>> On 9/5/2025 7:41 PM, Arne Vajhøj wrote:   
   >>>>> Original 1970's Pascal:   
   >>>>>   
   >>>>> * array passed as an address   
   >>>>> * compiler uses dimensions known at compile time to enforce   
   >>>>> boundary checks   
   >>>>>   
   >>>>> ISO Pascal, VMS Pascal, Delphi/FPC, Modula-2, Oberon:   
   >>>>>   
   >>>>> Two types of array parameters:   
   >>>>> - same as original 1970's Pascal   
   >>>>> - open arrays to accept arguments of different dimensions   
   >>>>>   
   >>>>> Open arrays:   
   >>>>> * array passed with meta information / by descriptor (VMS terminology) /   
   >>>>> as object (OOP terminology)   
   >>>>> * compiler use dimensions passed at runtime to enforce boundary checks   
      
   >>> You are inprecise. Classic Pascal has conformant array parameters,   
   >>> which pass bounds. Extended Pascal (and VMS Pascal) has schema   
   >>> types, including array schema, this is much more powerful than   
   >>> conformat arrays, and the same as conformat array could be   
   >>> checked, partially at compile time, check for indices staying in   
   >>> range sometimes must be done at runtime.   
   >>   
   >> The story I got was that:   
   >> * Wirth Pascal did not have it (conformant array)   
   >   
   > AFAIK Wirth Pascal had it. Several ports of Wirh Pascal to different   
   > machines done by others lost conformant arrays.   
   >   
   >> * ISO Pascal 1983 and 1990 added it for level 1   
   >> but not for level 0   
   >   
   > ISO Pascal 1983 simply sanctioned existing practice, that is   
   > existence of ports without conformant arrays. IIUC differences   
   > between level 1 ISO 1983 Pascal and Wirth Pascal were tiny.   
   >   
   >> But all before my time, so ...   
   >   
   > Before my time too, but some people spent effort to dig out   
   > various historical details.   
      
   Reagan probably know.   
      
   Anyway I can easily add the schema thing from extended ISO   
   Pascal.   
      
   program main3(input,output);   
      
   type   
    weird_array = array [-2..-1] of array [2..3] of integer;   
    twodim_integer_array(n1,n2,n3,n4:integer) = array [n1..n2] of array   
   [n3..n4] of integer;   
      
   procedure oldstyle(a : weird_array);   
      
   var   
    i, j : integer;   
      
   begin   
    for i := -2 to -1 do begin   
    for j := 2 to 3 do begin   
    write(a[i,j]);   
    end;   
    writeln;   
    end;   
   end;   
      
   procedure newstyle(a : array [low..upp:integer] of array   
   [low2..upp2:integer] of integer);   
      
   var   
    i, j : integer;   
      
   begin   
    for i := lower(a, 1) to upper(a, 1) do begin   
    for j := lower(a, 2) to upper(a, 2) do begin   
    write(a[i,j]);   
    end;   
    writeln;   
    end;   
   end;   
      
   procedure extstyle(a : twodim_integer_array);   
      
   var   
    i, j : integer;   
      
   begin   
    for i := lower(a, 1) to upper(a, 1) do begin   
    for j := lower(a, 2) to upper(a, 2) do begin   
    write(a[i,j]);   
    end;   
    writeln;   
    end;   
   end;   
      
   var   
    a : weird_array;   
    ax : twodim_integer_array(-2,-1,2,3);   
    i, j : integer;   
      
   begin   
    for i := -2 to -1 do   
    for j := 2 to 3 do   
    a[i,j] := i * j;   
    oldstyle(a);   
    newstyle(a);   
    for i := -2 to -1 do   
    for j := 2 to 3 do   
    ax[i,j] := i * j;   
    extstyle(ax);   
   end.   
      
   Arne   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|