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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,24d7acf9b853aac8 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!cleanfeed3-b.proxad.net!nnrp11-1.free.fr!not-for-mail Date: Mon, 09 Aug 2010 23:54:00 +0200 From: _FrnchFrgg_ User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.10) Gecko/20100619 Icedove/3.0.5 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: S-expression I/O in Ada References: <547afa6b-731e-475f-a7f2-eaefefb25861@k8g2000prh.googlegroups.com> <46866b8yq8nn$.151lqiwa0y2k6.dlg@40tude.net> <13b07f2c-2f35-43e0-83c5-1b572c65d323@y11g2000yqm.googlegroups.com> <13tpf7ya3evig$.h05p3x08059s$.dlg@40tude.net> <1omt2srxtpsga$.c3hbxthzo6cf.dlg@40tude.net> <1e4cch2df5uyb.18brqdd16dhv8.dlg@40tude.net> <14y70ke8am9qw$.2csc9eflvigg.dlg@40tude.net> <4c601b5c$0$7665$9b4e6d93@newsspool1.arcor-online.net> <9czktq4ntzq7.fhbsnocx0x4w$.dlg@40tude.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Message-ID: <4c6078f9$0$12500$426a74cc@news.free.fr> Organization: Guest of ProXad - France NNTP-Posting-Date: 09 Aug 2010 23:54:01 MEST NNTP-Posting-Host: 82.233.38.63 X-Trace: 1281390841 news-1.free.fr 12500 82.233.38.63:33729 X-Complaints-To: abuse@proxad.net Xref: g2news1.google.com comp.lang.ada:13023 Date: 2010-08-09T23:54:01+02:00 List-Id: Le 09/08/2010 21:59, Dmitry A. Kazakov a �crit : >> Yeah, that's a shame. I'd like to have case statements >> on bit maps, but also on other composite types. > > Yes, it is a type property that the domain is a set of identifiable values, > in fact, some mapping to an enumeration. > > The language should provide means to implement this interface with any > type. E.g. why I cannot specify this interface for String to be able to > write: > > case Get_Token is > when "type" => ... > when "package" => ... > when others => raise Syntax_Error; > end case; I think that you want pattern matching (http://en.wikipedia.org/wiki/Standard_ML#Algebraic_datatypes_and_pattern_matching) With the OCaml syntax, you can do match expression with | (Foo bar, [Int 4, u]) -> | _ -> and the engine will attempt unification ( http://en.wikipedia.org/wiki/Unification_%28computing%29) between expression and (Foo bar, [Int 4, u]), and if it succeeds, bar and u will be variables (immutable in caml) of the right value and right type so as to "fill in the blanks". (_ is a special-purpose variable whose content is discarded, because in the catch-all code we don't need a new name for expression -- here _ will match the whole expression of course). It is a pretty powerfull thing, and one of the reasons I keep using functionnal languages (I don't know if Lisp does it, though). Structured pattern matching begins to kick ass when you use big typed trees, like for instance ASTs. I don't know enough ada to even imagine how you would implement such a thing in Ada, if possible, or whether it already exists (but I gather no from what you say). (Sorry to intrude in an Ada newsgroup, I was just passing by) _FrnchFrgg_