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!news1.google.com!news3.google.com!feeder1.cambriumusenet.nl!feed.tweaknews.nl!193.201.147.71.MISMATCH!xlned.com!feeder3.xlned.com!news.astraweb.com!border3.a.newsrouter.astraweb.com!proxad.net!feeder1-2.proxad.net!cleanfeed3-a.proxad.net!nnrp11-2.free.fr!not-for-mail Date: Wed, 11 Aug 2010 19:51:23 +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: Structural unification (pattern matching) in Ada [was: Re: S-expression I/O in Ada] References: <547afa6b-731e-475f-a7f2-eaefefb25861@k8g2000prh.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> <4c6078f9$0$12500$426a74cc@news.free.fr> <4c6132d2$0$8378$426a74cc@news.free.fr> <4c61dafd$0$14549$426a74cc@news.free.fr> <4oebq9a8m8et$.gvv6eyo3umfh$.dlg@40tude.net> In-Reply-To: <4oebq9a8m8et$.gvv6eyo3umfh$.dlg@40tude.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Message-ID: <4c62e31a$0$10493$426a34cc@news.free.fr> Organization: Guest of ProXad - France NNTP-Posting-Date: 11 Aug 2010 19:51:22 MEST NNTP-Posting-Host: 82.233.38.63 X-Trace: 1281549082 news-4.free.fr 10493 82.233.38.63:34331 X-Complaints-To: abuse@proxad.net Xref: g2news1.google.com comp.lang.ada:13136 Date: 2010-08-11T19:51:22+02:00 List-Id: Le 11/08/2010 16:10, Dmitry A. Kazakov a �crit : > On Wed, 11 Aug 2010 01:04:29 +0200, _FrnchFrgg_ wrote: > >> Le 10/08/2010 13:19, Dmitry A. Kazakov a �crit : >>> On Tue, 10 Aug 2010 13:06:58 +0200, _FrnchFrgg_ wrote: >> >>>> Unification and pattern matching is independent of type inference. >>> >>> Did you mean the standard meaning of pattern matching instead of Standard >>> ML's Volap�k? >> >> I meant pattern matching as a ML construct, which is in fact structural >> unification. It can be done even without type inference, and only needs >> some kind of polymorphism; essentially you have an object and an >> expression made of (possibly nested) constructors, with leaves being >> either constants or variables, and the unification engine answers >> >> a) if the object could be obtained by the sequence of constructors, or not >> b) if yes, the content the variables would have had so that the sequence >> of constructors would produce the object. >> >> For convenience, you often have a list of expressions, and the engine >> executes the code of the first which fits the object. > > This translated into Ada terms, looks like an automated generation of > literals/aggregates. There is one step required for Ada, i.e. > interpretation of a text as code, since Ada is a compiled language. Objective Caml is also a compiled language, I don't really follow your point. > Main objection to all this is that it is hard-coded and involves the > object's structure (not nominal). Ada has similar mechanism, also > hard-coded and also structural. One generates S'Input and S'Output > attributes for stream I/O of built-in container types (arrays and records). > Another generates record and array aggregates. > > I don't like this either. I would like to see a more general mechanism that > would allow user-defined recursive non-generic implementations. Because > beyond literals and stream I/O there is an infinite number of cases where > this pattern apply. And secondly it should work for user-defined opaque > container types. I don't understand what Streams have to do with ML pattern matching. Just to be sure we are talking about the same thing, I read one of you wishing Ada had a more powerful/generic "switch" construct, and I noticed that the description of such a "switch" looked like a subset of structural unification as you can find in most functionnal languages. Perhaps the current Ada is powerful enough to write some function/code doing this switch machinery, but I was thinking it would be a new language construct (or an extension of "switch"). _FrnchFrgg_