From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,13ab88b30e0f779d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-12-28 08:00:04 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!colt.net!peernews3.colt.net!news0.de.colt.net!blackbush.xlink.net!blackbush.de.kpnqwest.net!news.erfurt.igrz.de!drcomp.erfurt.thur.de!not-for-mail From: Adrian Knoth Newsgroups: comp.lang.ada Subject: Re: Efficient Matrix? Date: 28 Dec 2002 15:48:11 GMT Organization: Modern Electronics Message-ID: References: <3e0b2a66_4@news.bluewin.ch> NNTP-Posting-Host: drcomp.erfurt.thur.de Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Server-Date: 28 Dec 2002 15:48:11 GMT User-Agent: slrn/0.9.7.4 (Linux) Xref: archiver1.google.com comp.lang.ada:32360 Date: 2002-12-28T15:48:11+00:00 List-Id: Bill Findlay wrote: >>> It's got nothing to do with the fact that the thing is heap allocated, >>> nor the fact that the bounds are not known at compile time. >> For the variable A it is even known, but I was not able to determine >> a valuable difference in memory-comsumption. > I get good results as follows, with GNAT 5.00w for MacOS X. What you get is exactly what I meant: The compiler optimizes if it is a constrained type and does nothing if it is unconstrained as the original poster wanted it. For sure it would be better to use a constrained subtype. Here your program modified to the asked context: with Ada.Text_IO; use Ada.Text_IO; procedure bla is type unconstrained_type is array (Positive range <>, Positive range <>) of Boolean; for unconstrained_type'Component_Size use 1; pragma Pack (unconstrained_type); type unconstrained_type_ptr is access unconstrained_type; A : unconstrained_type_ptr := new unconstrained_type (1 .. 10000, 1 .. 5000); begin Put_Line (Integer'Image (unconstrained_type'Component_Size)); Put_Line (Integer'Image (A.all'Size)); end bla; ------ adi@drcomp:/tmp$ ./bla 8 400000000 (last value is 50000000*8) -- mail: adi@thur.de http://adi.thur.de PGP: v2-key via keyserver Der merkt halt, dass das seine muttermilch ist, die gerade �bertragen wird. (user w�hrend des dd's der root-partition auf den fileserver)