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-7-bit X-Google-Thread: 103376,47bc849aad30d586 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-06-01 08:53:53 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: A standard package for config files is needed Date: 01 Jun 2002 11:44:32 -0400 Organization: NASA Goddard Space Flight Center (skates.gsfc.nasa.gov) Message-ID: References: <3CF5D7AC.975B0DB3@cs.tu-berlin.de> <4519e058.0205310825.868fe4a@posting.google.com> <4519e058.0205311424.2a7f77c4@posting.google.com> NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 1022946719 4131 128.183.220.71 (1 Jun 2002 15:51:59 GMT) X-Complaints-To: usenet@news.gsfc.nasa.gov NNTP-Posting-Date: 1 Jun 2002 15:51:59 GMT User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.ada:25154 Date: 2002-06-01T15:51:59+00:00 List-Id: dennison@telepath.com (Ted Dennison) writes: > Preben Randhol wrote in message > news:... > > One thing I'm sitting and thinking about now is if it is possible to > > make a procedure for storing a record or array and reading this back. I > > mean a generic procedure. > > It'd be pretty easy, as long as the generic can own the array type. Yes. My current Ada binding to the Windows ini API has: generic type Private_Type is limited private; Max_Width : Natural; -- maximum width of Image of Item. with function Value (Image : in String) return Private_Type; function Read_Private (File : in String; Section : in String; Keyword : in String; Default : in Private_Type) return Private_Type; -- Return private value associated with Keyword from Section in File. If -- Keyword is not found, Default is returned. generic type Private_Type is limited private; with function Image (Value : in Private_Type) return String; procedure Write_Private (File : in String; Section : in String; Keyword : in String; Item : in Private_Type); -- Write private value Item to Keyord in Section in File. The problem with this is that the file syntax for structured values is now controlled by the client, and is thus not standard. Maybe that's not really a Bad Thing. > Hmmm. One thing I'm thinking is that this task might be a bit easier > if the new version of Ada had the following: > > o The ability to specify the 'Image routine for user-defined types. > o 'Image being defined by default to perform a 'Image on each > component of a composite type (in order). We had a thread on this not long ago. The upshot was "just define an Image function". Getting the compiler to compose it for you is just not worth it, and also not going to happen. I may look into creating a variant of Auto_Text_IO that generates code to write aggregates to strings, rather than files; that would simplify this issue somewhat. -- -- Stephe