220 39420 <b39be2a8-c0c4-4887-a4ad-d11a50107aa9@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: "'Hamza Sood' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Contract attributes and trailing return types
Date: Thu, 26 Jul 2018 13:02:03 -0700 (PDT)
Lines: 156
Approved: news@gmane.org
Message-ID: <b39be2a8-c0c4-4887-a4ad-d11a50107aa9@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_10211_1294147454.1532635323114"
X-Trace: blaine.gmane.org 1532635199 13065 195.159.176.226 (26 Jul 2018 19:59:59 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Thu, 26 Jul 2018 19:59:59 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCP5NIM2SYKRBPGR5DNAKGQEVFOZF4Y@isocpp.org Thu Jul 26 21:59:55 2018
Return-path: <std-proposals+bncBCP5NIM2SYKRBPGR5DNAKGQEVFOZF4Y@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yw0-f198.google.com ([209.85.161.198])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCP5NIM2SYKRBPGR5DNAKGQEVFOZF4Y@isocpp.org>)
	id 1fimQU-0003JV-SD
	for gclcip-std-proposals@m.gmane.org; Thu, 26 Jul 2018 21:59:55 +0200
Original-Received: by mail-yw0-f198.google.com with SMTP id c204-v6sf1384169ywa.8
        for <gclcip-std-proposals@m.gmane.org>; Thu, 26 Jul 2018 13:02:06 -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:subject:mime-version:x-original-sender
         :reply-to:precedence:mailing-list:list-id:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=plpnH59oDqyBewMitTb6pH/UAtO1+LWHQ03DyFVauoA=;
        b=2LHjl/CoKWRXehTcUq/uHHJYy1oN2T8QGcf8SeXWfqPQoSJxoY1vi3I1aHTdUorsWY
         9SxAzpHA6CNqVq3Pr5FEA+u+62OA7gxuhxuGgcJTwYym/8fcO5Hy/l+Vst37esoYYG7T
         nXTjUiQSrIfXFydTrnF1eX8iP+irQVyfBGtBEIlLocItv+aojFcRjBCtqd0K19zf2zGo
         pa7xRV4UTbwo+anrIzQnndvMMLl0dwx34cwEyyOiMInLx33cuX9egUDPShWSI7yrOQKt
         /7gSylrGWdWEpRdU4LCz6b6THgCZc8kW+EhFS4+S21kUYXC6/B6ZKTHzG2X2HukGTQ6b
         OUHA==
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: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=plpnH59oDqyBewMitTb6pH/UAtO1+LWHQ03DyFVauoA=;
        b=dj+Wdj7AGE+2+aE1r6tDrxaYtKPSwBcEtrJlG7wlJqEfjZacI2bbUYMVJbm/Sw6Lrh
         //KWXHwX0efARCGwmwXg2nDcs3y0VLsY5dHvCvoMEbmDU/iE/Zamp50E0N4PXSVE51t1
         MjlxtXaMPqsVXeW/VrgFm/xinznPKpz63UaaIHffG1aGRUvTFNclrEOcR3Ot3OKUA5GB
         /G7XPJI6uW/s84hMUXRDHkMjyGUujF++yGTRTs9XYFatnopJcWpD8A+4bfhjoL56UkKb
         LqakHskH6UI/hy8m9/EHQxhqq9MW4FOn103YF2fBXl4b3B/PVcQ/fAFCZ85yzalmdNKM
         GkwA==
X-Gm-Message-State: AOUpUlE7RifOXo5iZT3MWZJMFd9JxQ3J6cs3rcMp0EY4eFp/f0fwFOcs
	EQOgFb5XsOiFxVRa/3Zjwl6Ydw==
X-Google-Smtp-Source: AAOMgpeRbSorDMC7+Gn15ZgkRl2X8njfUdQBl2taXccJrphjHg0VesfghaRlVNMqjW4VjmOyB5nQ1Q==
X-Received: by 2002:a81:5a56:: with SMTP id o83-v6mr955670ywb.59.1532635325527;
        Thu, 26 Jul 2018 13:02:05 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a81:a1d3:: with SMTP id y202-v6ls180314ywg.39.gmail; Thu, 26
 Jul 2018 13:02:03 -0700 (PDT)
X-Received: by 2002:a81:a611:: with SMTP id d17-v6mr36162ywh.2.1532635323737;
        Thu, 26 Jul 2018 13:02:03 -0700 (PDT)
X-Original-Sender: hamza_sood@me.com
X-Original-From: Hamza Sood <hamza_sood@me.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:39420
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/39420>

------=_Part_10211_1294147454.1532635323114
Content-Type: multipart/alternative; 
	boundary="----=_Part_10212_1566364973.1532635323115"

------=_Part_10212_1566364973.1532635323115
Content-Type: text/plain; charset="UTF-8"

If I'm interpreting the current draft standard correctly, it looks like 
contract attributes don't work particularly well with trailing return types.

E.g. here's an example from the proposal, re-written with a trailing return 
type:





*auto f(int x, int y)  [[expects: x>0]]  [[expects: y!=0]]  [[ensures result: result > x+y]] -> int;*


The return type ends up really far away from the rest of the function 
declaration, which makes it very difficult to spot.

I think it'd be better if contract attributes applied to a trailing return 
type are considered part of the function declaration, which would mean that 
the above could be written as:




*auto f(int x, int y) -> int  [[expects: x>0]]  [[expects: y!=0]]  [[ensures result: result > x+y]];*


-- 
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/b39be2a8-c0c4-4887-a4ad-d11a50107aa9%40isocpp.org.

------=_Part_10212_1566364973.1532635323115
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">If I&#39;m interpreting the current draft standard correct=
ly, it looks like contract attributes don&#39;t work particularly well with=
 trailing return types.<div><br></div><div>E.g. here&#39;s an example from =
the proposal, re-written with a trailing return type:</div><div><div class=
=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border: 1px=
 solid rgb(187, 187, 187); word-wrap: break-word;"><code class=3D"prettypri=
nt"><div class=3D"subprettyprint"><pre style=3D"caret-color: rgb(0, 0, 0); =
color: rgb(0, 0, 0);"><b><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">auto</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> f</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> x</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> y</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br>=C2=A0 </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">[[</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
expects</span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> x</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span sty=
le=3D"color: #066;" class=3D"styled-by-prettify">0</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">]]</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">[[</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify">expects</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> y</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">!=3D</span><span style=3D"color: #066;" class=3D"styled-by-prettify"=
>0</span><span style=3D"color: #660;" class=3D"styled-by-prettify">]]</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">[[</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">ensures result</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> result </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> x</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">+</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">y</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">]]</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">-&=
gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br></span></b></pre></div></cod=
e></div><br>The return type ends up really far away from the rest of the fu=
nction declaration, which makes it very difficult to spot.</div><div><br></=
div><div>I think it&#39;d be better if contract attributes applied to a tra=
iling return type are considered part of the function declaration, which wo=
uld mean that the above could be written as:</div><div><div class=3D"pretty=
print" style=3D"background-color: rgb(250, 250, 250); border: 1px solid rgb=
(187, 187, 187); word-wrap: break-word;"><code class=3D"prettyprint"><div c=
lass=3D"subprettyprint" style=3D"caret-color: rgb(102, 0, 102);"><pre style=
=3D"caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><b><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> f</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> x</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> y</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">-&gt;</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br>=C2=A0 </span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">[[</span><span style=3D"color: #000;" class=3D"styled-by-prettify">exp=
ects</span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> x</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span style=
=3D"color: #066;" class=3D"styled-by-prettify">0</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">]]</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">[[</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">expects</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> y</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">!=3D</span><span style=3D"color: #066;" class=3D"styled-by-prettify">0<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">]]</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">[[</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">ensures result</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> result </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> x</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">+</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify">y</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">]];</span></b></pre></div></code></div><br></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/b39be2a8-c0c4-4887-a4ad-d11a50107aa9%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/b39be2a8-c0c4-4887-a4ad-d11a50107aa9=
%40isocpp.org</a>.<br />

------=_Part_10212_1566364973.1532635323115--

------=_Part_10211_1294147454.1532635323114--

.
