comp.lang.ada
 help / color / mirror / Atom feed
From: naasking@gmail.com (Sandro Magi)
Subject: Re: Discriminant computation problem
Date: 15 Nov 2004 06:02:39 -0800
Date: 2004-11-15T06:02:39-08:00	[thread overview]
Message-ID: <7e2ad2d.0411150602.79ee1251@posting.google.com> (raw)
In-Reply-To: yjVld.906538$Gx4.504752@bgtnsc04-news.ops.worldnet.att.net

Jim Rogers <jimmaureenrogers@att.net> wrote in message news:<yjVld.906538$Gx4.504752@bgtnsc04-news.ops.worldnet.att.net>...
> 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;
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.



  reply	other threads:[~2004-11-15 14:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-15  1:11 Discriminant computation problem Sandro Magi
2004-11-15  3:24 ` Jim Rogers
2004-11-15 14:02   ` Sandro Magi [this message]
2004-11-15 15:16     ` Martin Krischik
2004-11-15 16:02     ` Dmitry A. Kazakov
2004-11-15 22:11 ` Nick Roberts
2004-11-15 23:25   ` tmoran
2004-11-16 20:00     ` Nick Roberts
2004-11-16 20:14       ` tmoran
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox