220 33127 <8cc43aaf-130d-4584-befe-8ace140b7b03@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Abdulla Herzallah <abdulla.herzallah@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: =?UTF-8?Q?=5Bstd=2Dproposals=5D_Re=3A_Proposal_to_extend_range=2Dbased_?=
	=?UTF-8?Q?=E2=80=98for=E2=80=99_loop_example=3A__for=281=3A10=29?=
Date: Wed, 5 Jul 2017 13:36:54 -0700 (PDT)
Lines: 160
Approved: news@gmane.org
Message-ID: <8cc43aaf-130d-4584-befe-8ace140b7b03@isocpp.org>
References: <524ec202-94cf-44cf-af4b-ff1339e6f394@isocpp.org>
 <fd09d6f6-d5c0-4443-b116-5160e12ce13e@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_3410_1179350889.1499287015036"
X-Trace: blaine.gmane.org 1499287026 11329 195.159.176.226 (5 Jul 2017 20:37:06 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 5 Jul 2017 20:37:06 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDK43EEOQMCRB2E36XFAKGQEUQW6SPA@isocpp.org Wed Jul 05 22:37:00 2017
Return-path: <std-proposals+bncBDK43EEOQMCRB2E36XFAKGQEUQW6SPA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-it0-f70.google.com ([209.85.214.70])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDK43EEOQMCRB2E36XFAKGQEUQW6SPA@isocpp.org>)
	id 1dSr2a-0002Il-FI
	for gclcip-std-proposals@m.gmane.org; Wed, 05 Jul 2017 22:36:52 +0200
Original-Received: by mail-it0-f70.google.com with SMTP id 188sf156463724itx.9
        for <gclcip-std-proposals@m.gmane.org>; Wed, 05 Jul 2017 13:36:58 -0700 (PDT)
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=r5p0xd6gFzisprydeCuRUX1AM9JIU1TFHm3NxkAO2yM=;
        b=q0etMThdyaKPGQ3C6DXVp6tOZinA90BIDEd/+GmnW8J2Gj2au1AkB/JXl2UyCbGlet
         FKAAycHrXAZGpurboT/hs9A8w0Lt7AqLvVyOMqw6su5Axp6BMWHsNprEegeY3XdTCz0/
         Dh+55YYXXlYQJ8fSWvFOLH2Ckivit/YU6iUf1cWOn4QRN1foaPIjD5D+nwVz2i0tFSc6
         bb/dxkMVPAvwXQkjk6VECFiysQ9lWxePnNqOQ9XPGSVFmkxSVGD3m3KNxKvvUmzTqrsG
         dEgKFD5D7DAB4YL4m//Qj2/B7JIWgFJdtoxYvaL/VPBh3YjqHMROt6X1QxIxKyyKVFv9
         y6yg==
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=r5p0xd6gFzisprydeCuRUX1AM9JIU1TFHm3NxkAO2yM=;
        b=ouGPdwV7UzYBUj2Nbpbi0cQVouXeUZZdf9jlAaBF8xH9Knu/VtGwj42CGE6JJ0PPpE
         7tfOtekWl9ND2BnV1iJHqa95lKmRFsuWdvbT+I5+mVW9Kxvkm1v9hpcGtWo+szP77E+b
         N8pCTjf33Ru5yWtSpDuF75Rch/h8A5qYqFmMyA1oWGH9fwvV+aTjeXQNXh0Pdk3HTvUP
         vR552I1zcBdef7vcfDty01yg6/7Wf5ScHnevBBzKJ080xbAUvd79rqz8Ux9qCbhtCXMD
         196imz5o2MZSit3cn7dkLEyB+oGMvEq4GXszf6UEy4cuvJv9rxEvai5s/7oovGIyPP/e
         NVVg==
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=r5p0xd6gFzisprydeCuRUX1AM9JIU1TFHm3NxkAO2yM=;
        b=DYhiCCe4McpWjHthPY7mA800YBvqwfpxELvLI+qIS/0Pi6cRq9uNUK+0IHBsHnwakf
         VpfxAM1R4kAm+/q5j6hhWiIilg+C+e08/nBGaZD/r/e7XAKrLvGiYIn+M1QkkWWPX4JI
         9JjWHa102PDhWYp5ksD+EdeCNTmvpTgE2/rQtBh0qXvQB/oXpPeVnJHLUYFlcTda7QaS
         m8fhJdc7fz78PtJCpEKE4yhUMTAQCznSfJxbtrKImEHpVV1JelYUNmWRqfGBkHzKupKR
         HhFFftMqXYpa9ENjhgSx7v0iLVPQ6pEEnR9hFvkdxv5u1gm65sP+GKvovmqGRXRizHS1
         ydrA==
X-Gm-Message-State: AIVw112v79aZRT84MGYZvOLYqZM6V7tUJdc+epTVNlrX4hZN/fd007uS
	bLQ6YoJjbLk618Zx
X-Received: by 10.36.84.82 with SMTP id t79mr10016179ita.8.1499287017660;
        Wed, 05 Jul 2017 13:36:57 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.132.218 with SMTP id o87ls10477686ioi.51.gmail; Wed, 05
 Jul 2017 13:36:55 -0700 (PDT)
X-Received: by 10.36.104.200 with SMTP id v191mr1136944itb.2.1499287015768;
        Wed, 05 Jul 2017 13:36:55 -0700 (PDT)
In-Reply-To: <fd09d6f6-d5c0-4443-b116-5160e12ce13e@isocpp.org>
X-Original-Sender: abdulla.herzallah@gmail.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:33127
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/33127>

------=_Part_3410_1179350889.1499287015036
Content-Type: multipart/alternative; 
	boundary="----=_Part_3411_1023800876.1499287015036"

------=_Part_3411_1023800876.1499287015036
Content-Type: text/plain; charset="UTF-8"

HI Nicol Bolas, 
Thanks for your comments.

The idea is to simplify the for-loop where it can be possible, and that 
help ensuring faster and readable coding, at the same time there should be 
0 impact on performance, which should be possible if adding this extension 
to the range-loop.

Adding literals support to range-loop is definitely possible "with relative 
ease" to the compiler syntax parser and code generator and generate code 
that is exactly as the standard for-loop but much easier to read with such 
brevity therefore less prone to errors.  Which was the main reasons for 
adding the range-for to the language after all.

The first two cases you presented does not match the idea as it require use 
of memory on the stack which is therefore not good idea. While the last 
example I am not sure I got you well on it, but it seems is what I am 
proposing in a different way, but none the less is still not possible 
without adding this feature to the language.

 cheers,
/Abdulla


On Tuesday, July 4, 2017 at 10:33:43 PM UTC+2, Nicol Bolas wrote:
>
>
>
> On Tuesday, July 4, 2017 at 2:20:37 PM UTC-4, Abdulla Herzallah wrote:
>>
>> HI ISO C++ Standard committee,
>>   
>> Apology if I am not following a proper specifications draft, I hope it 
>> will be reviewed by someone who can help in *evaluating or enhancing* 
>> this proposal.
>>
>
> Here's an even better idea:
>
> for(auto i; std::ints(10))
> {
> }
>
> Now we don't have to extend anything. We add one standard library 
> function, and we get everything you need. We can even add a literal to make 
> getting `size_t`s easier:
>
> for(auto i; std::ints(10z))
> {
> }
>
> Speaking of literals, we can even have literals that do the entire job, so 
> we don't need `std::ints` at all:
>
> for(auto i; 10rng)
> {
> }
>
> In short, there is no good reason to extend the language to do this. We 
> have plenty of tools to do the job adequately ourselves.
>

-- 
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/8cc43aaf-130d-4584-befe-8ace140b7b03%40isocpp.org.

------=_Part_3411_1023800876.1499287015036
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">HI Nicol Bolas,=C2=A0<div>Thanks for your comments.</div><=
div><br></div><div>The idea is to simplify the for-loop where it can be pos=
sible, and that help ensuring faster and readable coding, at the same time =
there should be 0 impact on performance, which should be possible if adding=
 this extension to the range-loop.</div><div><br></div><div>Adding literals=
 support to range-loop is definitely possible &quot;with relative ease&quot=
; to the compiler syntax parser and code generator and generate code that i=
s exactly as the standard for-loop but much easier to read with such brevit=
y therefore less prone to errors. =C2=A0Which was the main reasons for addi=
ng the range-for to the language after all.</div><div><br></div><div>The fi=
rst two cases you presented does not match the idea as it require use of me=
mory on the stack which is therefore not good idea. While the last example =
I am not sure I got you well on it, but it seems is what I am proposing in =
a different way, but none the less is still not possible without adding thi=
s feature to the language.<br></div><div><br></div><div>=C2=A0cheers,<br></=
div><div>/Abdulla</div><div><font color=3D"#666600" face=3D"monospace"><br>=
</font><br>On Tuesday, July 4, 2017 at 10:33:43 PM UTC+2, Nicol Bolas wrote=
:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bo=
rder-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><br><br>On T=
uesday, July 4, 2017 at 2:20:37 PM UTC-4, Abdulla Herzallah wrote:<blockquo=
te class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr">HI ISO C++ Standard committ=
ee,<div>=C2=A0=C2=A0<div>Apology if I am not following a proper specificati=
ons draft, I hope it will be reviewed by someone who can help in <u>evaluat=
ing or enhancing</u> this proposal.</div></div></div></blockquote><div><br>=
Here&#39;s an even better idea:<br><br><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:#008">for</span><span style=3D"color:#6=
60">(</span><span style=3D"color:#008">auto</span><span style=3D"color:#000=
"> i</span><span style=3D"color:#660">;</span><span style=3D"color:#000"> s=
td</span><span style=3D"color:#660">::</span><span style=3D"color:#000">int=
s</span><span style=3D"color:#660">(</span><span style=3D"color:#066">10</s=
pan><span style=3D"color:#660">))</span><span style=3D"color:#000"><br></sp=
an><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></span><=
/div></code></div><br>Now we don&#39;t have to extend anything. We add one =
standard library function, and we get everything you need. We can even add =
a literal to make getting `size_t`s easier:<br><br><div style=3D"background=
-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;bo=
rder-width:1px"><code><div><span style=3D"color:#008">for</span><span style=
=3D"color:#660">(</span><span style=3D"color:#008">auto</span><span style=
=3D"color:#000"> i</span><span style=3D"color:#660">;</span><span style=3D"=
color:#000"> std</span><span style=3D"color:#660">::</span><span style=3D"c=
olor:#000">ints</span><span style=3D"color:#660">(</span><span style=3D"col=
or:#066">10z</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></span><span style=3D"color:#660">}</span><span style=3D"color:#00=
0"><br></span></div></code></div><br>Speaking of literals, we can even have=
 literals that do the entire job, so we don&#39;t need `std::ints` at all:<=
br><br><div style=3D"background-color:rgb(250,250,250);border-color:rgb(187=
,187,187);border-style:solid;border-width:1px"><code><div><span style=3D"co=
lor:#008">for</span><span style=3D"color:#660">(</span><span style=3D"color=
:#008">auto</span><span style=3D"color:#000"> i</span><span style=3D"color:=
#660">;</span><span style=3D"color:#000"> </span><span style=3D"color:#066"=
>10rng</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"><b=
r></span><span style=3D"color:#660">}</span></div></code></div><br>In short=
, there is no good reason to extend the language to do this. We have plenty=
 of tools to do the job adequately ourselves.<br></div></div></blockquote><=
/div></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/8cc43aaf-130d-4584-befe-8ace140b7b03%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/8cc43aaf-130d-4584-befe-8ace140b7b03=
%40isocpp.org</a>.<br />

------=_Part_3411_1023800876.1499287015036--

------=_Part_3410_1179350889.1499287015036--

.
