220 22656 <CAB+4KH+KdPq5gP21+8mHcxFSOx80q7ZtEX33qjPSfT7kAzk4nw@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Andrew Tomazos <andrewtomazos@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Small contribution to readability (of at
 least my code)
Date: Sun, 15 Nov 2015 11:24:06 +0100
Lines: 301
Approved: news@gmane.org
Message-ID: <CAB+4KH+KdPq5gP21+8mHcxFSOx80q7ZtEX33qjPSfT7kAzk4nw@mail.gmail.com>
References: <CAJnXXojQZ+Jfh4Nnuyu+0E0t8g3E5q+VoAPCkYr_hkskC7q+4g@mail.gmail.com>
	<n289t3$cgh$1@ger.gmane.org>
	<CAJnXXoigRe0Auh9jFB7DU-DwYBH5jQfX+-zd8u3mymNzTYVhtg@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=001a1143c04e4052a3052491b1d4
X-Trace: ger.gmane.org 1447583052 12294 80.91.229.3 (15 Nov 2015 10:24:12 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sun, 15 Nov 2015 10:24:12 +0000 (UTC)
To: "std-proposals@isocpp.org" <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBD5KHQXXWYPRBR52UGZAKGQEDFB5S2A@isocpp.org Sun Nov 15 11:24:11 2015
Return-path: <std-proposals+bncBD5KHQXXWYPRBR52UGZAKGQEDFB5S2A@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lb0-f200.google.com ([209.85.217.200])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBD5KHQXXWYPRBR52UGZAKGQEDFB5S2A@isocpp.org>)
	id 1ZxuTi-0004bh-Qe
	for gclcip-std-proposals@m.gmane.org; Sun, 15 Nov 2015 11:24:10 +0100
Original-Received: by lbbko8 with SMTP id ko8sf43432546lbb.2
        for <gclcip-std-proposals@m.gmane.org>; Sun, 15 Nov 2015 02:24:10 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp_org.20150623.gappssmtp.com; s=20150623;
        h=mime-version:in-reply-to:references:date:message-id:subject:from:to
         :content-type: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=fUV+ldA89w8uScSdntFjG8R5b1HQ7yiw9womaDmZcoE=;
        b=uAKlPFM8NPdyJXZYPUBqsjdHst0dw+zQsL/Ile/71bKFZrdD6b5uRxCikkTb4+mL7i
         o+f4jDysOJZxJtT/kal5CInP042CcEANyFCEYUxX6LkCY+hTQyuYaQfj1crSVDHOAJ6v
         TYYd/+1g0T1jeV9HeBaGyia97/DxHvQXM+z4Mk3d0SBRKjqKoMcqBf9YD4krIbOj+BUv
         nE2BVxfT9ll6Epc0lju4aO2SfrLMN73YkDTGyvdXzU/w0d5ubfuqnTgnOmyb+vvO9xJW
         rCIIg15KX3VoIFbzNLJy5wnp98SPO7L5LnA7zJGT/qzApWKFjovYmmSWPGfxqRsREaGj
         vDPA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:in-reply-to:references:date
         :message-id:subject:from:to:content-type: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=fUV+ldA89w8uScSdntFjG8R5b1HQ7yiw9womaDmZcoE=;
        b=Ze5Dg4F8EhYMPt275d03gtHsd+rJA+i8d3dKyXT6lGGS8kjBPYMbKGL4+8eX4NDjNm
         PziWwDb2QaUpgZesW1zKEaqfbJyG4oYaxFqntG2ZkWD1Jd4gL9mpEmh5rUDGtG8H8SXb
         e0TMJdUK+gGktnBKpia+1VS4hkNdchNSS4eeUV3a5FcNeyY1We0IZqPjTlB8vvWTrfPG
         4y9PIbBBF/SwMu4gruX6qb/+Qyxj4yQsdibUwqEezW5mOh9VffOgTpk394U2xF5Ozyq+
         brdov36rK4IqeVEKlfaAtYm3DTqfHtgrF9Olvxw9O3STekgktN3pLquaOQzwlCR0MFBj
         7lEQ==
X-Gm-Message-State: ALoCoQnABkPiznJyCMlHHWCGpyAjog1XPwnQa+G5mInX8eSej8lRoXcIHgyMz14g/3OWMSyluytq
X-Received: by 10.25.81.21 with SMTP id f21mr4293461lfb.2.1447583050106;
        Sun, 15 Nov 2015 02:24:10 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.28.92.138 with SMTP id q132ls433021wmb.25.gmail; Sun, 15 Nov
 2015 02:24:06 -0800 (PST)
X-Received: by 10.28.46.137 with SMTP id u131mr12561701wmu.61.1447583046804;
        Sun, 15 Nov 2015 02:24:06 -0800 (PST)
Original-Received: from mail-wm0-x22d.google.com (mail-wm0-x22d.google.com. [2a00:1450:400c:c09::22d])
        by mx.google.com with ESMTPS id vl1si38815210wjc.33.2015.11.15.02.24.06
        for <std-proposals@isocpp.org>
        (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Sun, 15 Nov 2015 02:24:06 -0800 (PST)
Received-SPF: pass (google.com: domain of andrewtomazos@gmail.com designates 2a00:1450:400c:c09::22d as permitted sender) client-ip=2a00:1450:400c:c09::22d;
Original-Received: by wmec201 with SMTP id c201so137205040wme.0
        for <std-proposals@isocpp.org>; Sun, 15 Nov 2015 02:24:06 -0800 (PST)
X-Received: by 10.28.55.200 with SMTP id e191mr12608430wma.83.1447583046192;
 Sun, 15 Nov 2015 02:24:06 -0800 (PST)
Original-Received: by 10.28.113.91 with HTTP; Sun, 15 Nov 2015 02:24:06 -0800 (PST)
In-Reply-To: <CAJnXXoigRe0Auh9jFB7DU-DwYBH5jQfX+-zd8u3mymNzTYVhtg@mail.gmail.com>
X-Original-Sender: andrewtomazos@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of andrewtomazos@gmail.com designates 2a00:1450:400c:c09::22d as
 permitted sender) smtp.mailfrom=andrewtomazos@gmail.com;       dkim=pass
 header.i=@gmail.com;       dmarc=pass (p=NONE dis=NONE) header.from=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: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://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>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:22656
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/22656>

--001a1143c04e4052a3052491b1d4
Content-Type: text/plain; charset=UTF-8

I think there is a good idea in here.

Rather than making this narrow change, I'd prefer to see a larger proposal
for allowing a separate forward declaration of the public interface of a
class from the definition of the class.

Perhaps something like:

public class MyClass {
  MyClass(int = 0);

  int val() const;
  void val(int);
};

class MyClass {
public:
  MyClass(int = 0) { ... }

  int val() const { ... }
  void val(int) { ... }

private:
  int val_;
};

The compiler would check that the public interface forward declaration
matches the later class definition.  Consequently a human reader of the
header file only needs to read the public interface declaration, and isn't
distracted by implementation details, like inline function bodies and the
private section.  The interface documentation comments could be placed on
this forward declared public interface.

This is motivated by separating out interface specification from
implementation specification, which are fundamentally separate design
activities in software engineering.



On Sat, Nov 14, 2015 at 10:57 PM, John Yates <john@yates-sheets.org> wrote:

> Hi Larry,
>
> Thanks for the reply.  I posted to this list because my proposal is not a
> request for help but rather a suggestion for a (small) language change.  It
> adds no functionality so my note attempted to show how it might improve the
> presentation of source.  Apparently I failed to convey that clearly enough
> in my previous post.
>
> In the following only the declaration followed by definition within a
> class scope is disallowed:
>
> // global scope
> struct S;
> struct S { int i; };
> int f();
> int f() { return 0; }  // OK
>
> // within a namespace scope
> namespace N {
>   struct S;
>   struct S { int i; };
>   int f();
>   int f() { return 0; }  // OK
> }
>
> // within a class scope
> class C {
>   struct S;
>   struct S { int i; };
>   int f();
>   int f() { return 0; }  // ERROR!
> };
>
> I am proposing to allow that last case.
>
> /john
>
>
> On Sat, Nov 14, 2015 at 4:42 PM, Larry Evans <cppljevans@suddenlink.net>
> wrote:
>
>> On 11/14/2015 01:14 PM, John Yates wrote:
>> > I attempt to have one class per header.  This allows me to follow a
>> > file-wide organizing principle.
>> >
>> Hi John,
>>
>> I'd guess This topic is better covered in other newsgroups.
>> Try googling "c++.moderated coding style" to find a better
>> place to post you message.
>>
>> BTW, I like your idea:
>>
>>   a name should be introduced before being described
>>
>> which is a rule I use.
>>
>> -regards,
>> Larry
>>
>>
>>
>> --
>>
>> ---
>> 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.
>> Visit this group at
>> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>>
>
> --
>
> ---
> 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.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>

-- 

--- 
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

--001a1143c04e4052a3052491b1d4
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I think there is a good idea in here.<div><br></div><div>R=
ather than making this narrow change, I&#39;d prefer to see a larger propos=
al for allowing a separate forward declaration of the public interface of a=
 class from the definition of the class.</div><div><br></div><div>Perhaps s=
omething like:</div><div><br></div><div><font face=3D"monospace, monospace"=
 style=3D"font-size:12.8px">public class=C2=A0</font><span style=3D"font-si=
ze:12.8px;font-family:monospace,monospace">MyClass=C2=A0</span><span style=
=3D"font-size:12.8px;font-family:monospace,monospace">{</span><br></div><di=
v class=3D"gmail_extra"><div style=3D"font-size:12.8px"><font face=3D"monos=
pace, monospace" style=3D"font-size:12.8px">=C2=A0=C2=A0</font><span style=
=3D"font-size:12.8px;font-family:monospace,monospace">MyClass</span><span s=
tyle=3D"font-size:12.8px;font-family:monospace,monospace">(int =3D 0);</spa=
n><br></div><div style=3D"font-size:12.8px"><font face=3D"monospace, monosp=
ace"><br></font></div><div style=3D"font-size:12.8px"><font face=3D"monospa=
ce, monospace">=C2=A0 int val() const;</font></div><div style=3D"font-size:=
12.8px"><font face=3D"monospace, monospace">=C2=A0 void val(int);</font></d=
iv><div style=3D"font-size:12.8px">};</div><div style=3D"font-size:12.8px">=
<br></div><div style=3D"font-size:12.8px"><div style=3D"font-size:12.8px"><=
font face=3D"monospace, monospace">class=C2=A0</font><span style=3D"font-fa=
mily:monospace,monospace">MyClass=C2=A0</span><span style=3D"font-family:mo=
nospace,monospace;font-size:12.8px">{</span></div><div style=3D"font-size:1=
2.8px"><font face=3D"monospace, monospace">public:</font></div><div style=
=3D"font-size:12.8px"><font face=3D"monospace, monospace">=C2=A0=C2=A0</fon=
t><span style=3D"font-family:monospace,monospace">MyClass</span><span style=
=3D"font-family:monospace,monospace">(int =3D 0) { ... }</span></div><div s=
tyle=3D"font-size:12.8px"><font face=3D"monospace, monospace"><br></font></=
div><div style=3D"font-size:12.8px"><font face=3D"monospace, monospace">=C2=
=A0 int val() const { ... }</font></div><div style=3D"font-size:12.8px"><fo=
nt face=3D"monospace, monospace">=C2=A0 void val(int) { ... }</font></div><=
div style=3D"font-size:12.8px"><font face=3D"monospace, monospace"><br></fo=
nt></div><div style=3D"font-size:12.8px"><span style=3D"font-family:monospa=
ce,monospace;font-size:12.8px">private:</span><br></div><div style=3D"font-=
size:12.8px"><font face=3D"monospace, monospace">=C2=A0 int val_;</font></d=
iv><div style=3D"font-size:12.8px"><span style=3D"font-family:monospace,mon=
ospace;font-size:12.8px">};</span><br></div></div><div style=3D"font-size:1=
2.8px"><br></div><div style=3D"font-size:12.8px">The compiler would check t=
hat the public interface forward declaration matches the later class defini=
tion.=C2=A0 Consequently a human reader of the header file only needs to re=
ad the public interface declaration, and isn&#39;t distracted by implementa=
tion details, like inline function bodies and the private section.=C2=A0 Th=
e interface documentation comments could be placed on this forward declared=
 public interface.</div><div style=3D"font-size:12.8px"><br></div><div styl=
e=3D"font-size:12.8px">This is motivated by separating out interface specif=
ication from implementation specification, which are fundamentally separate=
 design activities in software engineering.</div><div style=3D"font-size:12=
..8px"><br></div><div style=3D"font-size:12.8px"><br></div><div style=3D"fon=
t-size:12.8px"><br></div></div><div class=3D"gmail_extra"><div class=3D"gma=
il_quote">On Sat, Nov 14, 2015 at 10:57 PM, John Yates <span dir=3D"ltr">&l=
t;<a href=3D"mailto:john@yates-sheets.org" target=3D"_blank">john@yates-she=
ets.org</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D=
"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,2=
04,204);border-left-style:solid;padding-left:1ex"><div dir=3D"ltr">Hi Larry=
,<div><br></div><div>Thanks for the reply.=C2=A0 I posted to this list beca=
use my proposal is not a request for help but rather a suggestion for a (sm=
all) language change.=C2=A0 It adds no functionality so my note attempted t=
o show how it might improve the presentation of source.=C2=A0 Apparently I =
failed to convey that clearly enough in my previous post.</div><div><br></d=
iv><div>In the following only the declaration followed by definition within=
 a class scope is disallowed:</div><div><br></div><div><div><font face=3D"m=
onospace, monospace">// global scope</font></div><div><font face=3D"monospa=
ce, monospace">struct S;</font></div><div><font face=3D"monospace, monospac=
e">struct S { int i; };</font></div><div><font face=3D"monospace, monospace=
">int f();</font></div><div><font face=3D"monospace, monospace">int f() { r=
eturn 0; } =C2=A0// OK</font></div><div><font face=3D"monospace, monospace"=
><br></font></div><div><font face=3D"monospace, monospace">// within a name=
space scope</font></div><div><font face=3D"monospace, monospace">namespace =
N {</font></div><div><font face=3D"monospace, monospace">=C2=A0 struct S;</=
font></div><div><font face=3D"monospace, monospace">=C2=A0 struct S { int i=
; };</font></div><div><font face=3D"monospace, monospace">=C2=A0 int f();</=
font></div><div><font face=3D"monospace, monospace">=C2=A0 int f() { return=
 0; } =C2=A0// OK</font></div><div><font face=3D"monospace, monospace">}</f=
ont></div><div><font face=3D"monospace, monospace"><br></font></div><div><f=
ont face=3D"monospace, monospace">// within a class scope</font></div><div>=
<font face=3D"monospace, monospace">class C {</font></div><div><font face=
=3D"monospace, monospace">=C2=A0 struct S;</font></div><div><font face=3D"m=
onospace, monospace">=C2=A0 struct S { int i; };</font></div><div><font fac=
e=3D"monospace, monospace">=C2=A0 int f();</font></div><div><font face=3D"m=
onospace, monospace">=C2=A0 int f() { return 0; } =C2=A0// ERROR!</font></d=
iv><div><font face=3D"monospace, monospace">};</font></div></div><div><br><=
/div><div>I am proposing to allow that last case.</div><span><font color=3D=
"#888888"><div><br></div><div>/john</div><div><br></div></font></span></div=
><div><div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Sat=
, Nov 14, 2015 at 4:42 PM, Larry Evans <span dir=3D"ltr">&lt;<a href=3D"mai=
lto:cppljevans@suddenlink.net" target=3D"_blank">cppljevans@suddenlink.net<=
/a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:=
0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);=
border-left-style:solid;padding-left:1ex"><span>On 11/14/2015 01:14 PM, Joh=
n Yates wrote:<br>
&gt; I attempt to have one class per header.=C2=A0 This allows me to follow=
 a<br>
&gt; file-wide organizing principle.<br>
&gt;<br>
</span>Hi John,<br>
<br>
I&#39;d guess This topic is better covered in other newsgroups.<br>
Try googling &quot;c++.moderated coding style&quot; to find a better<br>
place to post you message.<br>
<br>
BTW, I like your idea:<br>
<span><br>
=C2=A0 a name should be introduced before being described<br>
<br>
</span>which is a rule I use.<br>
<br>
-regards,<br>
Larry<br>
<span><font color=3D"#888888"><br>
<br>
<br>
--<br>
<br>
---<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%2Bunsubscribe@isocpp.org" target=3D=
"_blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" rel=3D"noreferrer" target=3D"_blank">http://groups.google.c=
om/a/isocpp.org/group/std-proposals/</a>.<br>
</font></span></blockquote></div><br></div>

<p></p>

-- <br>
<br>
--- <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" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div></div>

<p></p>

-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--001a1143c04e4052a3052491b1d4--

.
