220 33547 <722a37ea-6d3c-952a-f75e-376259a427cb@otoy.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Ross Smith <ross.smith@otoy.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: A more advanced switch
Date: Thu, 3 Aug 2017 09:18:33 +1200
Lines: 42
Approved: news@gmane.org
Message-ID: <722a37ea-6d3c-952a-f75e-376259a427cb@otoy.com>
References: <f8c908e2-d06f-4cd1-bda0-fe2b97fd21f1@isocpp.org>
 <9d888362-46f2-4317-b4ea-4376159d8ef1@isocpp.org>
 <ols5h1$450$1@blaine.gmane.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"; format=flowed
X-Trace: blaine.gmane.org 1501708724 4225 195.159.176.226 (2 Aug 2017 21:18:44 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 2 Aug 2017 21:18:44 +0000 (UTC)
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101
 Thunderbird/52.2.1
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCQ4ZXOXM4IK5A4JZQCRUBHV4TTCU@isocpp.org Wed Aug 02 23:18:39 2017
Return-path: <std-proposals+bncBCQ4ZXOXM4IK5A4JZQCRUBHV4TTCU@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qk0-f197.google.com ([209.85.220.197])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCQ4ZXOXM4IK5A4JZQCRUBHV4TTCU@isocpp.org>)
	id 1dd12I-0000TN-2F
	for gclcip-std-proposals@m.gmane.org; Wed, 02 Aug 2017 23:18:34 +0200
Original-Received: by mail-qk0-f197.google.com with SMTP id p135sf28170465qke.0
        for <gclcip-std-proposals@m.gmane.org>; Wed, 02 Aug 2017 14:18:40 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1501708719; cv=pass;
        d=google.com; s=arc-20160816;
        b=SfpzhQtQEdwPRswrVd77Ye5QlcaHTMUdwXEhMfzeQNxhXYflPkH5kTIoLs98WPbYFH
         soyrEotqXsU5jBWZ3hgUUJzC92wFv6z2Cq7Bme3Vbxpkz8NPqn/jZn2oY7tiM6GIdyg/
         Hxk1aY/Yfx4QdnFHr74E0vXTr9BzT8+s+IqhzhB7QCOdTCFVCKMjGswvecJ5ahK3MfK1
         TFU7wD0D+wpxCIQ5mYQZ+ipsdkVEqA5Imk4G8WPuo3WRQmM1Y8jGpivhSg6AEnjwG7NV
         onR9Zp/s5REZB/LGYESrAFxGlVg64Jy9j9gQJFM8baDUw7ypheMGqJsaQIXd7o3Tyij0
         2jOw==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:content-language
         :in-reply-to:mime-version:user-agent:date:message-id:from:references
         :newsgroups:to:subject:arc-authentication-results
         :arc-message-signature:dkim-signature:arc-authentication-results;
        bh=c7OG6STq2HuZbckbXdcDUTOke/wdSrZZqLWpi+DB7pQ=;
        b=I+C7e2dD4dZjLpmrHrEJpJXgwQn3ul8bay6k2qM+m01CoKfveBLT176nQYque25I3p
         j1xLZVlZJ2jiv5Qf7BmT4O3q9WLOIKV/EY0UKyGp+yGBYS0QdYZiNBrkVHk0tGvcO8Tv
         SytwKAVG5rZ1HANIEUxkpleBke5tTfXEU1FyeT26qg3UxcvGFao8CYABKMlJ0tL/+Uob
         N4i9sn99fcX78sG4rXElzFTfqtJ0N5L+DAx30MU41uUwaWQdRGOWOBJJQRe9MGQYiuAr
         2/cEkthkxXkjRlUJEux6xcu9eDF1k8PdpjmLZHrrRr0boUNuAnABpFaUoJjM5WrgghRX
         
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@otoy-com.20150623.gappssmtp.com header.b=RxtZQAIC;
       spf=pass (google.com: domain of ross.smith@otoy.com designates 2607:f8b0:400e:c05::22e as permitted sender) smtp.mailfrom=ross.smith@otoy.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=subject:to:newsgroups:references:from:message-id:date:user-agent
         :mime-version:in-reply-to:content-language:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe;
        bh=c7OG6STq2HuZbckbXdcDUTOke/wdSrZZqLWpi+DB7pQ=;
        b=OtBd3dihp0pQCUCnNftliDcg9tCq7TujUkTs5zkHtCtL8T0AX1zVj/DsertFfxxBO6
         v2A9o3U6qHvHFWuVeSkcJaI0LGgW0eKS0MfRdKUn/be1usOm5jiEFalLFXF8x9iTNPW6
         DT5mIppQeKmkxHMH7fPnkirTvzsJ8jqitlQHoQbFHcvt+c9YKQsjarCO5/0VApcwsaHe
         dBG8VHHx/KK4kuwX6LDMTPoZ8VStrRAroK82FdarC6UPZlBHiLhJTkszmu2Y4UUU4dOz
         2TqHUd5HyqNegQdgqIIwChkhMLnDq/s6IKGILUsCScqiVjTTSHp8WoqAru3zHV1QExJA
         yeEQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:subject:to:newsgroups:references:from:message-id
         :date:user-agent:mime-version:in-reply-to:content-language
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post
         :list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=c7OG6STq2HuZbckbXdcDUTOke/wdSrZZqLWpi+DB7pQ=;
        b=aks8Fh7z1yGbk94SZ9OrPqRpD9ao7xO12+3u/vGfEdipxEqoOeI8pbNbhwIE/NBq4z
         /gLdUmT0zQthWm0v2DwaWbIfSnlLn+dPr3XNBuZ+Lkt+/GvKjg5NinJwt0lcNl+BIVOB
         FmEN8ELgBj+1qA6wgUdi8rlSJU6T1F/u6DdWcecGdFpJwh06XKEDbBqLyxXKVR2XCCeX
         ow3RlI48/zIFxbKyoTrBVxIbO19iXNmK7+k+zzfd2xhiq0B66IvXlQfyKSfnG+ifNfp6
         AgOqIHcQxOnavfnu7Nylxtge+86p391Zlg0tTXfv0DsuWpGRgusMOz1vaFL0djJgpUHi 
X-Gm-Message-State: AIVw113pIRfPr652eMcpF3FNhD4CQfHfJ6ctfYlWcA215ls51goK2yYt
	q98muA8ARUeKKiM8
X-Received: by 10.237.57.229 with SMTP id m92mr17166814qte.29.1501708719780;
        Wed, 02 Aug 2017 14:18:39 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.29.199 with SMTP id d190ls272935iod.39.gmail; Wed, 02 Aug
 2017 14:18:38 -0700 (PDT)
X-Received: by 10.98.57.138 with SMTP id u10mr23731975pfj.227.1501708718168;
        Wed, 02 Aug 2017 14:18:38 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1501708718; cv=none;
        d=google.com; s=arc-20160816;
        b=xEVStUrwe9pAE2NDptXOYz4nF4DpWJsHOO2CC0Mavje06CbBzBd8Yzs7vCo7FRRzwh
         MIoIJXKWe3NwemGX5O1ZiFPETOqlw50MUoxvWJvsRqPp3COsSmu1SN9/nZOcTRFPAF65
         G5dzsBiJT/0CLVKQ3yHUQh1Hl7fUi3tcG6lDgNl/i8fB8Zpt4A1d1la0t5JfDehvjK5p
         WtNS9Sr8W8i4n8Yt89ms01enORpv1WwPl5mmNIs6nZx0etdibeqsSp40FH+7kDlUme0x
         +5yu3JnzffKozMVlO2TGoHz1/pnsqsGHbIittdwGO56pFaxhn0wswgHwxnlyM9AQ2QTJ
         RzEw==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=content-transfer-encoding:content-language:in-reply-to:mime-version
         :user-agent:date:message-id:from:references:newsgroups:to:subject
         :dkim-signature:arc-authentication-results;
        bh=0P6OE4PuCIC+63bxFCsnr1IrQYQMgiQDnoKsj0z5bfg=;
        b=OZl+PxElNSgsiiviN45EgDCFHOkEV2ag0kp2VWRskwpZIcflq43r138pjW9yf1rJTX
         prcX7z4tYKiO3tH9VwJIrz/SRQMCULIpMTIKho5IwLb80OuIF0/M/oPHiIW2Bqbc8ues
         MfxBXcf6AYdEbDYnF+wYbhHuwr8utomnY2JF1HOujGEku6HYgvK3d8aSnZyKdJJQadzd
         +Cm8CdAEhvcumUils2DMjQoGivu+juCsUdza/Zkp0nF4TN1NiGQ39c7Stzy2JdJSJPRG
         AsSp/+cWor3oqrcNJSdr3KFj6qxd8qfDmKItvB5oyXnvOcfWr7qGEJDS4W8gvC6a0nLL
         6e/g==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@otoy-com.20150623.gappssmtp.com header.b=RxtZQAIC;
       spf=pass (google.com: domain of ross.smith@otoy.com designates 2607:f8b0:400e:c05::22e as permitted sender) smtp.mailfrom=ross.smith@otoy.com
Original-Received: from mail-pg0-x22e.google.com (mail-pg0-x22e.google.com. [2607:f8b0:400e:c05::22e])
        by mx.google.com with ESMTPS id x11si10089797pfe.328.2017.08.02.14.18.38
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 02 Aug 2017 14:18:38 -0700 (PDT)
Received-SPF: pass (google.com: domain of ross.smith@otoy.com designates 2607:f8b0:400e:c05::22e as permitted sender) client-ip=2607:f8b0:400e:c05::22e;
Original-Received: by mail-pg0-x22e.google.com with SMTP id u185so25871583pgb.1
        for <std-proposals@isocpp.org>; Wed, 02 Aug 2017 14:18:38 -0700 (PDT)
X-Received: by 10.99.43.212 with SMTP id r203mr24111037pgr.321.1501708717658;
        Wed, 02 Aug 2017 14:18:37 -0700 (PDT)
Original-Received: from [10.0.0.87] (125-236-198-58.adsl.xtra.co.nz. [125.236.198.58])
        by smtp.gmail.com with ESMTPSA id t29sm14025843pfl.4.2017.08.02.14.18.35
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 02 Aug 2017 14:18:36 -0700 (PDT)
Original-Newsgroups: gmane.comp.lang.c++.isocpp.proposals
In-Reply-To: <ols5h1$450$1@blaine.gmane.org>
Content-Language: en-US
X-Original-Sender: ross.smith@otoy.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@otoy-com.20150623.gappssmtp.com header.b=RxtZQAIC;       spf=pass
 (google.com: domain of ross.smith@otoy.com designates 2607:f8b0:400e:c05::22e
 as permitted sender) smtp.mailfrom=ross.smith@otoy.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:33547
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/33547>

On 2017-08-02 21:20, Bo Persson wrote:
> On 2017-08-01 23:53, Vishal Oza wrote:
>> I like the idea of adding new of adding to the switch statement but I 
>> think lets take it futher
>> switch (v)
>> {
>> case v= [1,5]: //incusive 1 to 5 1 <= v <= 5
>>        Dosomething();
>>        break;
>> case v = (5, 10): //exclusive range 5 < v < 10
>>        doSomethingelse1();
>>        break;
>> case v = (10, 50 ]: // 10 < v <= 50
>>        doSomethingElse2();
>>        break;
>> case v = (50,...) // 50 < v
>>        doSomethingElse3();
>>        break;
>> case v = 50:
>>        doSomethingElse4();
>>        break;
>> }
>> Valid for only if v is numeric also add multi variable values and strings
>>
> 
> If you have large ranges, the compiler might translate that similar to 
> an if-statement anyway. Especially the (50,...) cannot easily be used in 
>   a jump table.

There's only so much elaboration that could be added to the switch 
statement before it stops offering any meaningful advantage in 
convenience or readability over just manually writing the equivalent 
sequence of if-elses.

Ross Smith

-- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/722a37ea-6d3c-952a-f75e-376259a427cb%40otoy.com.

.
