Re: ML-style pattern matching in C-like languages

=?ISO-8859-1?Q?J=FCrgen_Kahrs?= <Juergen.Kahrs@vr-web.de>
19 Dec 2005 00:09:56 -0500

          From comp.compilers

Related articles
ML-style pattern matching in C-like languages rsc@swtch.com (Russ Cox) (2005-12-15)
Re: ML-style pattern matching in C-like languages just-for-news-frido@q-software-solutions.de (Friedrich Dominicus) (2005-12-15)
Re: ML-style pattern matching in C-like languages gtg983q@mail.gatech.edu (Ben Chambers) (2005-12-15)
Re: ML-style pattern matching in C-like languages torbenm@app-2.diku.dk (2005-12-15)
Re: ML-style pattern matching in C-like languages RLake@oxfam.org.uk (2005-12-15)
Re: ML-style pattern matching in C-like languages rvclayton@acm.org (2005-12-15)
Re: ML-style pattern matching in C-like languages haberg@math.su.se (2005-12-19)
Re: ML-style pattern matching in C-like languages Juergen.Kahrs@vr-web.de (=?ISO-8859-1?Q?J=FCrgen_Kahrs?=) (2005-12-19)
Re: ML-style pattern matching in C-like languages rsc@swtch.com (Russ Cox) (2005-12-23)
Re: ML-style pattern matching in C-like languages nr@eecs.harvard.edu (2005-12-29)
Re: ML-style pattern matching in C-like languages Vladimir.Y.Morozov@gmail.com (2006-01-18)
| List of all articles for this month |

From: =?ISO-8859-1?Q?J=FCrgen_Kahrs?= <Juergen.Kahrs@vr-web.de>
Newsgroups: comp.compilers
Date: 19 Dec 2005 00:09:56 -0500
Organization: Compilers Central
References: 05-12-036
Keywords: C, design

Russ Cox wrote:


> One might envision a syntax like:
>
> if(n ~ Node(OADD, Node(OMUL, ?x, ?y), ?z))
>
> or even
>
> if(n ~ OADD(OMUL(?x, ?y), ?z))
>
> to match (and bind subexpressions in) an expression of
> the form x*y+z. But maybe sometimes I care about the types:
>
> if(n ~ OADD(OMUL(?x, ?y, .type ~ TLONG), ?z))


Do you really have to change the language C for this ? Write a
function which does the matching. Granted, within the limits of C, the
struct to be matched has to be built up before matching, and this
takes some lines of code. But would you really sacrifice compatibility
with C merely for getting some shorthand notation in return ?



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.