[Issue 5348] Variable Length Arrays
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Feb 13 13:01:03 PST 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5348
--- Comment #3 from bearophile_hugs at eml.cc 2011-02-13 12:58:28 PST ---
Ada language too supports stack-allocation of 2D arrays with run-time sizes, an
example:
with Ada.Text_Io; use Ada.Text_Io;
with Ada.Float_Text_Io; use Ada.Float_Text_Io;
with Ada.Integer_Text_Io; use Ada.Integer_Text_Io;
procedure Two_Dimensional_Arrays is
type Matrix_Type is array(Positive range <>, Positive range <>) of Float;
Dim_1 : Positive;
Dim_2 : Positive;
begin
Get(Item => Dim_1);
Get(Item => Dim_2);
-- Create an inner block with the correctly sized array
declare
Matrix : Matrix_Type(1..Dim_1, 1..Dim_2);
begin
Matrix(1, Dim_2) := 3.14159;
Put(Item => Matrix(1, Dim_2), Fore => 1, Aft => 5, Exp => 0);
New_Line;
end;
-- The variable Matrix is popped off the stack automatically
end Two_Dimensional_Arrays;
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list