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,f6f130eea077b8f8 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-05-22 00:52:00 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!news-FFM2.ecrc.net!uio.no!193.216.69.35.MISMATCH!dax.net!juliett.dax.net!not-for-mail Newsgroups: comp.lang.ada Subject: Re: 'Write attribute vs Write procedure. References: <7vk7ck7iwc.fsf@vlinux.voxelvision.no> From: Ole-Hjalmar Kristensen Message-ID: <7v65o3772e.fsf@vlinux.voxelvision.no> User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 22 May 2003 07:51:22 GMT NNTP-Posting-Host: 193.216.12.150 X-Complaints-To: abuse@tele2.no X-Trace: juliett.dax.net 1053589882 193.216.12.150 (Thu, 22 May 2003 09:51:22 MET DST) NNTP-Posting-Date: Thu, 22 May 2003 09:51:22 MET DST Organization: Tele2 Norway AS Public Access Xref: archiver1.google.com comp.lang.ada:37630 Date: 2003-05-22T07:51:22+00:00 List-Id: tmoran@acm.org writes: > >> Personally, I think using the default 'write is only reasonable > >> in the very simplest cases. If something is big, or complicated, > >> I'd write my own 'write for it. > > > >Yes, but that removes much of the attraction of using a stream in the > >first place. It should only be necessary to do your own write if you > >wanted another representation of it in the external format. A prime > >example of rendering a very nice feature of the language pretty much > >unusable because of a poor implementation. > > I disagree. It is convenient when you use it that you needn't > distinguish between a 'write that will write in a canonical, vs a special > external format. In the OP's case, it was probably simpler to get the > program up and running with the standard 'write, rather than having to > make his own, and then worry about doing something special as a matter of > performance tuning. Yes, but why should performance tuning be necessary for the simple cases, like a record without tags or discriminants? The compiler has all the information necessary to make an *efficient* write. I figure the answer is that if you do it the simple-minded way by calling the write procedure of every component, you don't have to do any special compile time analysis, just note that this type has its own write already defined, and don't generate one for it. But the opposite strategy should also be simple : if on of the components has a special write, do it by calling write on every component, else just transfer it as a blob. > > You also still have use at a higher level, eg > type Sound_Bytes is record > Time : Ada.Calendar.Time; > Audio : Wave; > Title : String(1 .. 10); > end record; > If you have a special Wave'write, you can say > Sound_Bytes'write > and it will do the standard thing for Time and Name but call your > special routine for Audio, so you probably don't need to make your > own Sound_Bytes'write. At it's own abstraction level, Sound_Bytes is > neither big nor complicated, so you probably don't need a special 'write. -- Ole-Hj. Kristensen ****************************************************************************** * You cannot consistently believe this sentence. ******************************************************************************