From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 7 Oct 92 16:15:39 GMT From: deccrl!caen!spool.mu.edu!darwin.sura.net!aplcen.apl.jhu.edu!ddsdx2.jhuapl .edu!dlc@bloom-beacon.mit.edu (Dave Collard x7468) Subject: Re: Problem with inefficiency and records with variant parts Message-ID: <1992Oct7.161539.9771@aplcen.apl.jhu.edu> List-Id: In sidou@litsun.epfl.ch (Dominique Sidou) w rites: >First, I want to reformulate the problem, I think it >was not enough precise in my first post: >Suppose: >PACKAGE qwe IS > subtype t1 is Integer; > type t2 is array(1..1000) of Integer; > type t3 is array (1..1000) of Boolean; > subtype st is integer range 1..3; > type t (s : st := 1) is record > case s is > when 1 => c1 : t1; > when 2 => c2 : t2; > when 3 => c3 : t3; > end case; > end record; > procedure fillt1(v1 : in out t1); > procedure fillt2(v2 : in out t2); > procedure fillt3(v3 : in out t3); > procedure fillt(v : in out t; s : in st); >END qwe; >package body qwe is > procedure fillt1(v1 : in out t1) is > begin > v1 := 1; > end fiilt1; > procedure fillt2(v2 : in out t2) is > begin > for i in v2'range loop > v2(i) := 2; > end loop; > end fillt2 > procedure fillt3(v3 : in out t3) is > begin > for i in v2'range loop > v3(i) := true; > end loop; > end fillt3; > procedure fillt(v : in out t; s : in st) is > begin > -- ?? How can I Do ?? > -- to cast v to v(s) and then call > -- the corresponding filling procedure > -- without any copy of a structure of > -- type t2 or t3. > case s is > when 1 => > v := (s => 1, c1 => 0); > fillt1(v.c1); > when 2 => > v := (s => 2, c2 => (others => 0)); -- useless copy to avoid !! > fillt1(v.c2); > when 3 => > v := (s => 3, c3 => (others => false)); -- useless copy to avoid !! > fillt1(v.c3); > end case; > end fillt; --This does not do a copy on my machine: procedure fillt(v : out t; s : in st) is ret : t(s); begin case s is when 1 => fillt1(ret.c1); when 2 => fillt2(ret.c2); when 3 => fillt3(ret.c3); end case; v := ret; end fillt; >end qwe; >I think now the problem is well formulated. >Precisions: >1: I know that if my components were >references it would be easy. But i have to deal >with static structures. >2: Working with Verdix Ada 6.0.3 on Sun4/SunOs 4.1.1 >Thanks in advance for any ideas, >/DS. >Sidou Dominique, Ecole Polytechnique Federale de Lausanne, >DI-LIT-INN138, Ecublens, CH-1015 Lausanne, Suisse >tel: 693.26.48. e-mail: sidou@litsun.epfl.ch >-- >Sidou Dominique, Ecole Polytechnique Federale de Lausanne, >DI-LIT-INN138, Ecublens, CH-1015 Lausanne, Suisse >tel: 693.26.48. e-mail: sidou@litsun.epfl.ch --Thor dlc@ddsdx2.jhuapl.edu collard@capsrv.jhuapl.edu