220 36437 <98aadf70-3c33-476a-af1e-3fed88bf4789@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Ryan Nicholl <r.p.nicholl@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: operator[](...)
Date: Sat, 30 Dec 2017 16:40:15 -0800 (PST)
Lines: 172
Approved: news@gmane.org
Message-ID: <98aadf70-3c33-476a-af1e-3fed88bf4789@isocpp.org>
References: <ea8aec36-305c-48ca-aedc-0db120fd8fcc@isocpp.org>
 <8bbeac1f-f698-4e49-9e1f-4cb1ab389b09@isocpp.org>
 <acd594ce-5289-44de-b760-19e655d84a7b@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_31591_1478594473.1514680815987"
X-Trace: blaine.gmane.org 1514680705 1046 195.159.176.226 (31 Dec 2017 00:38:25 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sun, 31 Dec 2017 00:38:25 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCTNLHWRU4LBB4HDUDJAKGQEIIV5MWY@isocpp.org Sun Dec 31 01:38:21 2017
Return-path: <std-proposals+bncBCTNLHWRU4LBB4HDUDJAKGQEIIV5MWY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vk0-f70.google.com ([209.85.213.70])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCTNLHWRU4LBB4HDUDJAKGQEIIV5MWY@isocpp.org>)
	id 1eVRdn-00086x-DM
	for gclcip-std-proposals@m.gmane.org; Sun, 31 Dec 2017 01:38:15 +0100
Original-Received: by mail-vk0-f70.google.com with SMTP id a67sf17255305vki.21
        for <gclcip-std-proposals@m.gmane.org>; Sat, 30 Dec 2017 16:40:18 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=/n6HZvZNtKwzIiABfx6R7v36Fp5PZ1OSkLbEALr/khQ=;
        b=nmEf4QjUcAsZl2u/rdNTbx457BAjkQdYPppYTjR9NHzXKDKhRFT2vrow2kGPv2M70p
         +5TVAMqcxsH31aNu6yIc765RaJ5ksRjsstl6G0wy53WjutogGAuyNFKy0CcEW6qRie5W
         r2fFl3g9TZqC7oOLaalqOQszrna8tSHcWFVkxYoRTtSW/28tUtHQnb6L+pxd1QJMLHvj
         A7oqmkpq5ttTgWU9IsO8E7M4fPoHqWbJmJjQ3YTzjn04XCWg3TmjVqHrXmvCFC3fBiag
         3qe36R+AyVw5voYzN5a4IJ8qTm0ZsOmQxmxezDPoX0/9EVt7sM+2mN7y83B1v2T2ipG+
         rKmQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=/n6HZvZNtKwzIiABfx6R7v36Fp5PZ1OSkLbEALr/khQ=;
        b=ucNBfqRmdVW9OdnrMow6G/nmUsmd03QHJflKQ60ObWSKu+ZwNFMzHJmgKXJ1iHC/ml
         8KX734o9Z7yT1rbfFAZWuKNeGDNLlw4GY3XbECeNBnL1TNeiuGA2xQKGzSVc8Zh8BwJe
         uPlC4P48/TKfHY6+IKmC2cSgWKt+CCINRS9y6ai/+1kjZDsmYzUi52kUGAnS61X4c8Iz
         tCmY1f8kDiRjxcHVfKc7SWQeINYhYFFEHyVgxHM/q0tdmFPweo0/Tx3nZBNLW9+D5zHd
         19KETmWO79Ink3uRZQ2igoo7ffnvRxGm42dbtCzNWS4In57J/2qvhtexs+DsJ5TOOaxO
         K40w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=/n6HZvZNtKwzIiABfx6R7v36Fp5PZ1OSkLbEALr/khQ=;
        b=JDWj4BkOT5fK02wey0bcfMvjj9WFyyyl25GECrrEykIssNDDWkoP6zdgxNCVYwCPhe
         h0FJtUlmkRJiN4Rja4U0MH4piV46CxeRBtgNPjUjNWdFu3EClNzrLh8rCcXbMLgUa4Qs
         bli7ur+5du7zDKnU2R3N0ixCN3a+Uepi7PcQt44xSHf7x6C2SLcgBQ3D4/yxMeifPpyM
         zcG84fOIdJfKUP2yJfl6D4A+x7wvtPJdsEnjALE9wbDK5vMlLJp7VHE3vZNllHbjCdUX
         MPKHQ729pdvXz6ui/LHC1AbzmThrJcXXbxkvOUlk2lpbrul0zaVb3Rn9WzI7pwky0Mr0
         tc5w==
X-Gm-Message-State: AKGB3mJ0tEs8gLzs/XwlRT8B4Ex58DMJQYUpXQFRmbix3b6lqYUAvVZH
	9csGG1Aqu1T68JXl727bBkhO+w==
X-Google-Smtp-Source: ACJfBosZ9JmfXpjwgtNIFV90N2Nl/X1CnRiXH+FA9IPxiFrwK8cZlDEYfksO6Ya0HJ11I9eHq6uo2Q==
X-Received: by 10.31.80.199 with SMTP id e190mr17497493vkb.22.1514680818151;
        Sat, 30 Dec 2017 16:40:18 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.159.48.202 with SMTP id k10ls6627638uab.20.gmail; Sat, 30 Dec
 2017 16:40:16 -0800 (PST)
X-Received: by 10.31.94.215 with SMTP id s206mr3620118vkb.1.1514680816567;
        Sat, 30 Dec 2017 16:40:16 -0800 (PST)
In-Reply-To: <acd594ce-5289-44de-b760-19e655d84a7b@isocpp.org>
X-Original-Sender: r.p.nicholl@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: 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:36437
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/36437>

------=_Part_31591_1478594473.1514680815987
Content-Type: multipart/alternative; 
	boundary="----=_Part_31592_1647229906.1514680815988"

------=_Part_31592_1647229906.1514680815988
Content-Type: text/plain; charset="UTF-8"

Why would anyone currently want to overloaded operator `[]` is beyond me.  
It is confusing and could be misconstrued as an array index by newer users 
to the language.  Yes, there is a work around, but this is a workaround to 
something that shouldn't need to be worked around as it makes it more 
difficult to use and understand the language. (/sarcasm)

On Saturday, December 16, 2017 at 11:40:42 AM UTC-5, Jack Adrian Zappa 
wrote:
>
>
>
> On Saturday, November 25, 2017 at 4:11:21 PM UTC-5, Nicol Bolas wrote:
>>
>> On Saturday, November 25, 2017 at 2:08:25 PM UTC-5, Ryan Nicholl wrote:
>>>
>>>
>>> My suggestion is to allow overloading operator [] with multiple 
>>> arguments, e.g.:
>>>
>>> class image
>>> {
>>>   ...
>>> public:
>>>   ...
>>>
>>>   pixel & operator[](size_t x, size_t y)
>>>   {
>>>     return internal_data[x+y*width];
>>>   }
>>> };
>>>
>>> /// used like:
>>>
>>> image my_image = ...;
>>> ...
>>> pixel px = my_image[5, 3];
>>>
>>> Would be most useful where I see 
>>> [{...}]
>>>
>>> currently. E.g.:
>>> output[{x,y}] = value;
>>> when processing images.
>>>
>>>
>> You've essentially undermined your proposal by highlighting a problem 
>> with most multi-argument `[]` proposals.
>>
>> As it currently stands `output[x, y]` already has a meaning. Namely, it's 
>> equivalent to `output[y]`; the entire text between the `[]` is taken as a 
>> single expression, rather than a list of arguments.
>>
>> So you have to invent a new syntax to make what you want possible. 
>> Namely, `output[{x, y}]`.
>>
>
> Why would anyone currently want to use a comma separated list inside of a 
> `[]` is beyond me.  It is confusing and could be misconstrued as a 
> multidimensional array index by newer users to the language.  Yes, there is 
> a work around, but this is a workaround to something that shouldn't need to 
> be worked around as it makes it more difficult to use and understand the 
> language.
>

-- 
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/98aadf70-3c33-476a-af1e-3fed88bf4789%40isocpp.org.

------=_Part_31592_1647229906.1514680815988
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Why would anyone currently want to overloaded operator
 `[]` is beyond me.=C2=A0 It is confusing and could be misconstrued as an a=
rray index by newer users to the language.=C2=A0 Yes, there
 is a work around, but this is a workaround to something that shouldn&#39;t=
=20
need to be worked around as it makes it more difficult to use and=20
understand the language. (/sarcasm)<br><br>On Saturday, December 16, 2017 a=
t 11:40:42 AM UTC-5, Jack Adrian Zappa wrote:<blockquote class=3D"gmail_quo=
te" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;paddi=
ng-left: 1ex;"><div dir=3D"ltr"><br><br>On Saturday, November 25, 2017 at 4=
:11:21 PM UTC-5, Nicol Bolas wrote:<blockquote class=3D"gmail_quote" style=
=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"=
><div dir=3D"ltr">On Saturday, November 25, 2017 at 2:08:25 PM UTC-5, Ryan =
Nicholl wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-le=
ft:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><br>=
My suggestion is to allow overloading operator [] with multiple arguments, =
e.g.:<br><br><div style=3D"background-color:rgb(250,250,250);border-color:r=
gb(187,187,187);border-style:solid;border-width:1px"><code><div><span style=
=3D"color:#008">class</span><span style=3D"color:#000"> image<br></span><sp=
an style=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0 </spa=
n><span style=3D"color:#660">...</span><span style=3D"color:#000"><br></spa=
n><span style=3D"color:#008">public</span><span style=3D"color:#660">:</spa=
n><span style=3D"color:#000"><br>=C2=A0 </span><span style=3D"color:#660">.=
...</span><span style=3D"color:#000"><br><br>=C2=A0 pixel </span><span style=
=3D"color:#660">&amp;</span><span style=3D"color:#000"> </span><span style=
=3D"color:#008">operator</span><span style=3D"color:#660">[](</span><span s=
tyle=3D"color:#000">size_t x</span><span style=3D"color:#660">,</span><span=
 style=3D"color:#000"> size_t y</span><span style=3D"color:#660">)</span><s=
pan style=3D"color:#000"><br>=C2=A0 </span><span style=3D"color:#660">{</sp=
an><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color=
:#008">return</span><span style=3D"color:#000"> internal_data</span><span s=
tyle=3D"color:#660">[</span><span style=3D"color:#000">x</span><span style=
=3D"color:#660">+</span><span style=3D"color:#000">y</span><span style=3D"c=
olor:#660">*</span><span style=3D"color:#000">width</span><span style=3D"co=
lor:#660">];</span><span style=3D"color:#000"><br>=C2=A0 </span><span style=
=3D"color:#660">}</span><span style=3D"color:#000"><br></span><span style=
=3D"color:#660">};</span><span style=3D"color:#000"><br><br></span><span st=
yle=3D"color:#800">/// used like:</span><span style=3D"color:#000"><br><br>=
image my_image </span><span style=3D"color:#660">=3D</span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#660">...;</span><span style=3D"col=
or:#000"><br></span><span style=3D"color:#660">...</span><span style=3D"col=
or:#000"><br>pixel px </span><span style=3D"color:#660">=3D</span><span sty=
le=3D"color:#000"> my_image</span><span style=3D"color:#660">[</span><span =
style=3D"color:#066">5</span><span style=3D"color:#660">,</span><span style=
=3D"color:#000"> </span><span style=3D"color:#066">3</span><span style=3D"c=
olor:#660">];</span><span style=3D"color:#000"><br></span></div></code></di=
v><br>Would be most useful where I see <div style=3D"background-color:rgb(2=
50,250,250);border-color:rgb(187,187,187);border-style:solid;border-width:1=
px"><code><div><span style=3D"color:#660">[{...}]</span></div></code></div>=
<br> currently. E.g.:<br><div style=3D"background-color:rgb(250,250,250);bo=
rder-color:rgb(187,187,187);border-style:solid;border-width:1px"><code><div=
><span style=3D"color:#000">output</span><span style=3D"color:#660">[{</spa=
n><span style=3D"color:#000">x</span><span style=3D"color:#660">,</span><sp=
an style=3D"color:#000">y</span><span style=3D"color:#660">}]</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#660">=3D</span><span styl=
e=3D"color:#000"> value</span><span style=3D"color:#660">;</span><span styl=
e=3D"color:#000"><br></span></div></code></div>when processing images.<br><=
br></div></blockquote><br>You&#39;ve essentially undermined your proposal b=
y highlighting a problem with most multi-argument `[]` proposals.<br><br>As=
 it currently stands `output[x, y]` already has a meaning. Namely, it&#39;s=
 equivalent to `output[y]`; the entire text between the `[]` is taken as a =
single expression, rather than a list of arguments.<br><br>So you have to i=
nvent a new syntax to make what you want possible. Namely, `output[{x, y}]`=
..<br></div></blockquote><div><br></div><div>Why would anyone currently want=
 to use a comma separated list inside of a `[]` is beyond me.=C2=A0 It is c=
onfusing and could be misconstrued as a multidimensional array index by new=
er users to the language.=C2=A0 Yes, there is a work around, but this is a =
workaround to something that shouldn&#39;t need to be worked around as it m=
akes it more difficult to use and understand the language.<br></div></div><=
/blockquote></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/98aadf70-3c33-476a-af1e-3fed88bf4789%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/98aadf70-3c33-476a-af1e-3fed88bf4789=
%40isocpp.org</a>.<br />

------=_Part_31592_1647229906.1514680815988--

------=_Part_31591_1478594473.1514680815987--

.
