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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,3abdaa39e1c27f49 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!news.mathworks.com!newsfeed.mathworks.com!news-peer0-test!btnet!news-in.ntli.net!newsrout1-win.ntli.net!ntli.net!newsfeed01.sul.t-online.de!newsmm00.sul.t-online.de!t-online.de!news.t-online.com!not-for-mail From: Martin Krischik Newsgroups: comp.lang.ada Subject: Re: Discriminant computation problem Date: Mon, 15 Nov 2004 16:16:24 +0100 Organization: None Message-ID: <1428466.J51lMFusOX@linux1.krischik.com> References: <7e2ad2d.0411150602.79ee1251@posting.google.com> Reply-To: martin@krischik.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: news.t-online.com 1100532245 02 27344 Ez37XD-re0sNRLh 041115 15:24:05 X-Complaints-To: usenet-abuse@t-online.de X-ID: ZkvwnvZAQeUiTKZrLkjQdbH9qQWxlsgJjJmS2zDSu-vSS6dXmMJk0v User-Agent: KNode/0.8.0 Xref: g2news1.google.com comp.lang.ada:6207 Date: 2004-11-15T16:16:24+01:00 List-Id: Sandro Magi wrote: > Jim Rogers wrote in message > news:... >> You might want to reconsider your design. >> First of all, your chosen example is a very poor way to represent >> a bit vector in Ada. This appears to be an Ada translation of a C >> or C++ programming approach. > > As I said, it was just the simplest example of what I was trying to > do. It's not what I'm actually trying to do. > >> My second point deals with your desire to perform a calculation >> on a parameterized value. The more acceptable way to accomplish >> such an end is the use of a generic package rather than a >> record discriminant. The use of a generic package provides >> encapsulation and information hiding for your operations that >> prevent you from unnecessarily exposing internal data structures. > > I was trying to avoid the extra step of instantiating a generic > package. Furthermore, the types from one package would not be > interoperable with the types from another package would they? ie. > using my Bit_Vector example and assuming the package defines an Append > operation: > > procedure Test is > package Bit_Vector_1024 is new Bit_Vector(1024); > package Bit_Vector_2048 is new Bit_Vector(2048); > > b1024 : Bit_Vector_1024.Bit_Vector; > b2048 : Bit_Vector_2048.Bit_Vector; Hint: When you have a package and a type with the same name you can't "use" that package without risking name clashes. That's why most packages have name for multiples like Unbounded_Strings. > begin > ... > (initialize some data in each vector) > ... > --this would fail to type check wouldn't it? > Append(Data=>b1024, To=>b2048); > end Test; > > Sorry for asking something so obvious, but I can't check this myself > at the moment. Deppends on how the types and the parameters are defined. If both Bit_Vector_1024.Bit_Vector and Bit_Vector_2048.Bit_Vector are subtypes with a common ancestor then it well could work: In Ada, with it's extensive type system, getting the types right is more important then getting the procedures right. With Regards Martin -- mailto://krischik@users.sourceforge.net http://www.ada.krischik.com