From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 33255 invoked by alias); 15 Jul 2015 15:09:33 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 33243 invoked by uid 89); 15 Jul 2015 15:09:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Wed, 15 Jul 2015 15:09:31 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 0D5BCABA5; Wed, 15 Jul 2015 15:09:28 +0000 (UTC) Date: Wed, 15 Jul 2015 15:21:00 -0000 From: Michael Matz To: Richard Biener cc: Richard Biener , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Add 'switch' statement to match.pd language In-Reply-To: <9742E78F-EF7F-4AFB-8F26-D3B5871BA366@gmail.com> Message-ID: References: <9742E78F-EF7F-4AFB-8F26-D3B5871BA366@gmail.com> User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-IsSubscribed: yes X-SW-Source: 2015-07/txt/msg01296.txt.bz2 Hi, On Wed, 15 Jul 2015, Richard Biener wrote: > >> (switch > >> (A) B > >> (B) C > >> (C) D > >> E) > > > >The lispy way would have been > > > > (switch > > (A) (B) > > (C) (D) > > (E) (F) > > G) > > > >i.e. parenthesize the result as well, which then would be unambiguously > > That's just atoms vs. Expressions. But if the result is no atom, you'd want parentheses. Similar if the condition is no expression but an atom, you'd want to leave out parentheses as well. My point is, that both condition and result are at the same level, and hence should be subject to the same parenthesis rules, namely: surrounding parens by default, optional for atoms. > Like (Plus @0 @1) vs. Plain @1. So you suggest to require ((plus @0 > @1)) here to make it unambiguous? No :) Just look at your example again: (switch (A) B ) Both A and B are at the same level, and are both expressions, but still you parenthesize them differently; that can't be right. You also don't write (switch ((plus @0 @1)) (@0) ) You write (switch (plus @0 @1) (@0) ) And as syntactic sugar you are allowed to leave out the parens around @0 as it's an atom: (switch (plus @0 @1) @0 ) Similar, if the condition is an atom you should be able to leave the parens away: (switch cond (minus @0 @1) ) (given a predicate 'cond' defined appropriately). Ciao, Michael.