comp.lang.ada
 help / color / mirror / Atom feed
* unconstrained subtype in component declaration, tagged OO
@ 2011-03-26 20:24 Nasser M. Abbasi
  2011-03-26 20:42 ` Dmitry A. Kazakov
  0 siblings, 1 reply; 6+ messages in thread
From: Nasser M. Abbasi @ 2011-03-26 20:24 UTC (permalink / raw)


I am learning a bit about Ada OO, and I have simple problem,
hopefully with simple answer, but not able to find one so far.

I want to make an object, but the declaration of the tagged record
would include an array in it. The size of this array, at the
time of declaration is not know. But will be when the
object is created.

So, what is the correct way to declare such an object?

Here is my ads package for the object:

-------------------foo.ads-------
package foo is
    type foo_t is tagged private;
    -- primitive operations
    function make(n:natural) return foo_t;
private
     type u_t is array(natural range<>) of float;

     type foo_t is tagged record
          u : u_t:= (others=>0.0);  -- problem here
     end record;
end foo;
----------------------------

Later on, (when I can get this to compile :), I wanted
to write

with foo; use foo;
...
o : foo_t := make(100);   


I can solve this problem by making a generic package,
and use the size as the generic of the package, but
I really do not want to do that. I want to keep
things very simple for now, as I am just learning
this, and wanted the most simple solution.

As I am now learning Ada again, I am sure I will be back here
with more questions to the experts.

thanks
--Nasser






^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-03-27 20:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-26 20:24 unconstrained subtype in component declaration, tagged OO Nasser M. Abbasi
2011-03-26 20:42 ` Dmitry A. Kazakov
2011-03-26 22:50   ` Nasser M. Abbasi
2011-03-27  3:23     ` John B. Matthews
2011-03-27  9:42     ` Dmitry A. Kazakov
2011-03-27 20:58       ` Nasser M. Abbasi

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