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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f3437064e1091fec X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-15 04:31:16 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: wojtek@power.com.pl (Wojtek Narczynski) Newsgroups: comp.lang.ada Subject: Re: What evil would happen? Date: 15 Jul 2003 04:31:16 -0700 Organization: http://groups.google.com/ Message-ID: <5ad0dd8a.0307150331.673b7782@posting.google.com> References: <5ad0dd8a.0307111151.4a08f95a@posting.google.com> NNTP-Posting-Host: 62.111.211.178 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1058268676 7714 127.0.0.1 (15 Jul 2003 11:31:16 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 15 Jul 2003 11:31:16 GMT Xref: archiver1.google.com comp.lang.ada:40285 Date: 2003-07-15T11:31:16+00:00 List-Id: ka@sorry.no.email (Kenneth Almquist) wrote in message news:... > wojtek@power.com.pl (Wojtek Narczynski) wrote: > > I feel like with SML like tagged union datatypes I'd be done long > > ago... Is there an AI for this maybe? > > I'm not sure what the problem is here. In SML you can write > things such as: > > datatype tree = Leaf of int > | Tree of { > value : int, > left : tree, > right : tree > } > | Empty > > In Ada, you achieve the same effect by writing: > > type Tree_Tag is (Leaf, General_Tree, Empty); > type Tree(Tag : Tree_Tag); > type Tree_Ptr is access Tree; > type Tree(Tag : Tree_Tag) is record > case Tag is > when Leaf => > Leaf : Integer; > when General_Tree => > Value : Integer; > Left : Tree_Ptr; > Right : Tree_Ptr; > when Empty => > null; > end case; > end record; > Thanks for the example. Regards, Wojtek