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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8e0e21432ac3eca6 X-Google-Attributes: gid103376,public From: G Subject: *\\~record depth~//* Date: 1999/11/09 Message-ID: <3826DFBF.52AC2680@interact.net.au>#1/1 X-Deja-AN: 545914734 Content-Transfer-Encoding: 7bit Organization: Humanity X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-11-09T00:00:00+00:00 List-Id: 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