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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,640b65cbfbab7216 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!1g2000prg.googlegroups.com!not-for-mail From: Eric Hughes Newsgroups: comp.lang.ada Subject: Re: Untyped Ada? Date: Sat, 12 Apr 2008 09:50:24 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <47F26C46.3010607@obry.net> <44d88b93-6a90-4c18-8785-2164934ba700@a9g2000prl.googlegroups.com> NNTP-Posting-Host: 166.70.57.218 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1208019025 31925 127.0.0.1 (12 Apr 2008 16:50:25 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 12 Apr 2008 16:50:25 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: 1g2000prg.googlegroups.com; posting-host=166.70.57.218; posting-account=5RIiTwoAAACt_Eu87gmPAJMoMTeMz-rn User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:20891 Date: 2008-04-12T09:50:24-07:00 List-Id: On Apr 4, 9:16 am, Graham wrote: > I haven't been using Ada for all that long, but I have been thinking > that a kinder, gentler version would be nice in some circumstances. > Not necessarily *no* type-checking, but the ability to mix, say, > integers, fixed-point types and floats in an equation without > cluttering up the code with conversions. If you'd like one, write one using a record with a variant part. type Number_Type is ( Integer_Type, Fixed1_Type, Float1_Type ) ; -- etc. type Number is record T : Number_Type ; case T is when Integer_Type => Integer_Value : Integer ; when Fixed1_Type => Fixed1_Value : Fixed1 ; when Float1_Type => Float1_Value : Float1 ; end case ; end record ; Now, when you choose your floating and fixed point types and then also write your arithmetic operations and conversions, you may realize why there's no universal one of these that's appropriate for everybody. I'm sure you can make one that's appropriate for you. As for syntax, you'll have to use explicit constructor functions for constants. Perhaps you'd like to declare it as "type N is ...". Eric