comp.lang.ada
 help / color / mirror / Atom feed
* *\\~record depth~//*
@ 1999-11-09  0:00 G
  1999-11-08  0:00 ` Nick Roberts
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: G @ 1999-11-09  0:00 UTC (permalink / raw)


  I am still learning (autodidactically) what is probably painfully
silly and simple to many of you.
However - I use the Gnat compiler to learn what is possible (though
not necessarily sensible) in Ada.

  Some time ago Matt Heaney explained to me here that a record
declaration
must only contain elements which are delimited (perhaps not in those
exact words)
   I was playing with types tonight and I found that I could extend one
tagged record such that I may
include the record from which it was extended in its element list.

----------------------------------------------------------------------------------------

package Problem is

              -- a PROBLEM is defined by its COMPONENTs and their
ACTIONs.

  type Component is (Single, Dependent, Group);           -- for e.g.
  type Component_List is array (Component'First..Component'Last) of
Component;

            -- type Action is (Direct, Indirect); --

  type Simple_Problem is tagged
  record
    Unit : Component;          --  a Unit
  end record;

  type Complex_Problem is new Simple_Problem with
  record
    Simple_Structure : Component_List;          -- deeper STRUCTURE
    Simple_Recursive_Reference : Simple_Problem;
  end record;

  type Compound_Problem is new Complex_Problem with
  record
    Complex_Structure : Component_List;           -- even deeper
STRUCTURE
    Complex_Recursive_Reference : Complex_Problem;
  end record;

end Problem;
------------------------------------------------------------------------------

I would have thought (my grasp of symbolic logic being as admittedly
limited
as it is) that placing a Simple_Problem within the Complex_Problem type
would fluff with the compiler, but it didn't.  So, obviously one may do
this sort of thing 'legally' in Ada.

Would there be any programming situations where this sort of thing would
apply
or is it toally irrelevant ?  If records are included within
abstractions of themselves
would that make it unneccessarily complex to assign properties to
instances
of the records/objects ?

possibility 1) - you will tell me it is totally silly

possibility 2) - you will tell me some horrendously complex tale of
syntax and simpler ways of doing
                      precisely the same things.

I am just wondering out loud and as I have this wonderful facility of
communication with the
boffins I thought I would ask.


-Graeme
-Australia





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

end of thread, other threads:[~1999-11-16  0:00 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-11-09  0:00 *\\~record depth~//* G
1999-11-08  0:00 ` Nick Roberts
1999-11-09  0:00   ` Robert Dewar
1999-11-09  0:00     ` David C. Hoos, Sr.
1999-11-09  0:00       ` Robert Dewar
1999-11-09  0:00 ` oops - same with neater formatting G
1999-11-15  0:00 ` *\\~record depth~//* Mario Amado Alves
1999-11-15  0:00   ` Matthew Heaney
1999-11-16  0:00     ` G
1999-11-16  0:00       ` Robert Dewar
1999-11-16  0:00       ` Robert Dewar
1999-11-16  0:00         ` Robert A Duff
1999-11-16  0:00       ` Robert Dewar

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