220 10449 <567223bf-127c-4d55-8be4-5c5915e1f561@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: maksimpustovoyt@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Add compiler time attributes like c#
Date: Wed, 30 Apr 2014 09:38:30 -0700 (PDT)
Lines: 216
Approved: news@gmane.org
Message-ID: <567223bf-127c-4d55-8be4-5c5915e1f561@isocpp.org>
References: <e9533cfc-f35c-4313-aaaf-a6d3d8aa00f9@isocpp.org>
 <CAOU91OOiEnyF6m=8hetJxCsBxs1UkRYu3xn_LOFuMk0xuv8WcQ@mail.gmail.com>
 <85900e94-bdc6-45eb-87ec-d3fd9e43d4cd@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_1384_8877558.1398875910719"
X-Trace: ger.gmane.org 1398875919 15923 80.91.229.3 (30 Apr 2014 16:38:39 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 30 Apr 2014 16:38:39 +0000 (UTC)
Cc: gmisocpp@gmail.com
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCRP3Q4MT4MRBB6OQSNQKGQEAFAQOPI@isocpp.org Wed Apr 30 18:38:34 2014
Return-path: <std-proposals+bncBCRP3Q4MT4MRBB6OQSNQKGQEAFAQOPI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yh0-f71.google.com ([209.85.213.71])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCRP3Q4MT4MRBB6OQSNQKGQEAFAQOPI@isocpp.org>)
	id 1WfXWj-0005v3-6T
	for gclcip-std-proposals@m.gmane.org; Wed, 30 Apr 2014 18:38:33 +0200
Original-Received: by mail-yh0-f71.google.com with SMTP id i57sf7118508yha.2
        for <gclcip-std-proposals@m.gmane.org>; Wed, 30 Apr 2014 09:38:32 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:cc: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:content-type;
        bh=4jLuNBQETjunI8ipAj07HOj0wqOYObIByaGNGMth0Jg=;
        b=TSqmqP4GktL4uwQIVCjmFa+jUUhBTPC+oFZSukcRPYQyIV0EKxvVXFmIXvH3bBF+d+
         1ZYHCNgtWrh5Wosz6HHrC2MQpaVct/Rk+g73DZLu1jgFkkmgj2nuL4qGtJd7B+S6cfp8
         OoVJC7NiTc4DsJJXzdi5IZVu2xcirRvYA+lAJTI3Hlt4UFnQy/6bEGq/MC/BOHFqzNb8
         DMTHy5WV3CrZwfjAmylyV1PMSkVPg74rX5QLbKCwxye/LfHd4pVqwsxDBlBlVfm7Fbn/
         VGC2rhFCzYOZwk6t89pr5DJd9NMVnzMrzpY1KIDZgWuRGy8/p3b2iV5BpVb16cXBYBOB
         bDmw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:cc: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:content-type;
        bh=4jLuNBQETjunI8ipAj07HOj0wqOYObIByaGNGMth0Jg=;
        b=m+dLVaeAlo5i66h+D15weNDKCG0uRa30H24lvYqxEMP1D+/Ks8v5ZSDoUCJljTq9+/
         7JWzeqHxxdlZHJt1n+wqexzsRL4hp5hKNoexzdDtZxHilzrlmVxoIbap/jyG72HJ2HZF
         OLgQ7/gUtCScQfw5zf9uMjc/KfQNzpBEg848VbQf22Q6ZlzJvwBYCprwNnysUytfwdc0
         ZfaEJPsaZUilxjYSaKk5LuBzhgfU/BLZa5TIOArGptjC9+raXDTcknbY8mKMGxySjhwR
         hj8BDym0sTvQ6GdHabwQBPvzEdY5QLVDxnt2dcnXPp3OzB8NWdcyVPWcqVz+jfCAIHmi
         iccQ==
X-Gm-Message-State: ALoCoQkchcef8SyMAF7i+vRicpu3HOAs41ju3lK7+4NHeiVvFBFbGARIfnx7OHAUBoTW4mcitG6P
X-Received: by 10.236.209.130 with SMTP id s2mr2466102yho.18.1398875912106;
        Wed, 30 Apr 2014 09:38:32 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.182.142.102 with SMTP id rv6ls335963obb.48.gmail; Wed, 30 Apr
 2014 09:38:31 -0700 (PDT)
X-Received: by 10.182.220.232 with SMTP id pz8mr38896obc.13.1398875911081;
        Wed, 30 Apr 2014 09:38:31 -0700 (PDT)
In-Reply-To: <85900e94-bdc6-45eb-87ec-d3fd9e43d4cd@isocpp.org>
X-Original-Sender: maksimpustovoyt@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: <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: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:10449
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/10449>

------=_Part_1384_8877558.1398875910719
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

This is different than C++11 attributes.
This is extendable Metadata about class which you can use in real time.
For example, I want to print my object in nice format. I can do something=
=20
like that:
[AttributeExtension]  //This predefine attribute "AttributeExtension" tells=
=20
compiler that this class can be used as Attribute for other classes:
struct MyAttribute {
    string Name;
    string Description;
    MyAttribute(string name; string description=3D "") : Name(name),=20
Description(description) {}
}
[AttributeExtension] // This predefine attribute "AttributeExtension" tells=
=20
compiler that this class can be used as Attribute for other classes:
struct AgeRange {=20
    int Minum;
 int Maximum;
 AgeRange(int minum; int maximum)  Minum(minum), Maximum(maximum) {}
}

.... some time later in code...

[METADATA(true)] // tells compiler to geneate meta data about my class
[MyAttribute("Person", "This this class 'Person' description")] // called=
=20
MyAttribute::MyAttribute("class A", "This this class 'A' description")
struct Person {
 [MyAttribute("Fist Name")] // called MyAttribute::MyAttribute("class A",=
=20
"This this class 'A' description")
 string FirstName;
 [MyAttribute("Last Name", "Person's last name")] // called=20
MyAttribute::MyAttribute("class A", "This this class 'A' description")=20
 string LastName;
 [AgeRange(18,50)]
 int ValidAge;
}

.... some time later in code...

bool CanRegisterPerson(Person &person) {=20
 if (person.ValidAge < Person::Member::ValidAge::AgeRange::Minimum) return=
=20
false;
 if (person.ValidAge > Person::Member::ValidAge::AgeRange::Maximum) return=
=20
false;
 return true;
}

bool RegisterPerson(Person &person) {=20
 if (!CanRegisterPerson(person)) {
  printf("Cannot register person %s:%s, %s:%s because age %d must be in=20
between %d and %d\n"
   ,person::Member::FirstName::MyAttribute::Name.c_str()
   ,person.FistName.c_str()
   ,person::Member::LastName::MyAttribute::Name.c_str()
   ,person.LastName.c_str()  =20
   ,person.Age
   ,Person::Member::ValidAge::AgeRange::Minimum
   ,Person::Member::ValidAge::AgeRange::Maximum
   return false;
  );
  return true; =20
 }
}



On Wednesday, April 30, 2014 8:59:51 AM UTC-4, gmis...@gmail.com wrote:

>
> This is fun.
> On Thursday, May 1, 2014 12:13:44 AM UTC+12, Klaim - Jo=C3=ABl Lamotte wr=
ote:
>>
>> C++11 already have =E2=80=8Battributes. See:=20
>> en.cppreference.com/w/cpp/language/attributes
>>
> Yes sadly, it's true.=20
>
=20
>
>> Or are you suggesting specific attributes to be standardised?
>> If yes, then your example is not clear at all to me.
>>
>> I'd quite like to see [[warn_unused_result]] become standard.
>
> http://stackoverflow.com/questions/2042780/how-to-raise-warning-if-return=
-value-is-disregarded-gcc-or-static-code-check
>
> btw. anyone think we're ready to add things like [[unused_arg]] yet?
>
> Thanks
>

--=20

---=20
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 e=
mail 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-proposa=
ls/.

------=_Part_1384_8877558.1398875910719
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>This is different than C++11 attributes.</div><div>Th=
is is extendable Metadata about class which you can use in real time.</div>=
<div>For example, I want to print my object in nice format. I can do someth=
ing like that:</div><div>[AttributeExtension]&nbsp; <font color=3D"#38761d"=
>//This predefine attribute "AttributeExtension" tells compiler that this c=
lass can be used as Attribute for other classes:</font><br>struct MyAttribu=
te {<br>&nbsp;&nbsp;&nbsp; string Name;<br>&nbsp;&nbsp;&nbsp; string Descri=
ption;<br>&nbsp;&nbsp;&nbsp; MyAttribute(string name; string description=3D=
 "") : Name(name), Description(description) {}<br>}<br>[AttributeExtension]=
<font color=3D"#6aa84f"> // This predefine attribute "AttributeExtension" t=
ells compiler that this class can be used as Attribute for other classes</f=
ont>:<br>struct AgeRange {&nbsp;<br>&nbsp;&nbsp;&nbsp; int Minum;<br>&nbsp;=
int Maximum;<br>&nbsp;AgeRange(int minum; int maximum)&nbsp; Minum(minum), =
Maximum(maximum) {}<br>}</div><div><br></div><div><font color=3D"#76a5af">.=
... some time later in code...</font></div><div><font color=3D"#76a5af"></fo=
nt><br>[METADATA(true)] <font color=3D"#38761d">// tells compiler to geneat=
e meta data about my class</font><br>[MyAttribute("Person", "This this clas=
s 'Person' description")] // called MyAttribute::MyAttribute("class A", "Th=
is this class 'A' description")<br>struct Person {<br>&nbsp;[MyAttribute("F=
ist Name")] // called MyAttribute::MyAttribute("class A", "This this class =
'A' description")<br>&nbsp;string FirstName;<br>&nbsp;[MyAttribute("Last Na=
me", "Person's last name")] // called MyAttribute::MyAttribute("class A", "=
This this class 'A' description")&nbsp;<br>&nbsp;string LastName;<br>&nbsp;=
[AgeRange(18,50)]<br>&nbsp;int ValidAge;<br>}</div><div><br><font color=3D"=
#38761d">... some time later in code...</font></div><div><font color=3D"#38=
761d"><br></font></div><div>bool CanRegisterPerson(Person &amp;person) {&nb=
sp;<br>&nbsp;if (person.ValidAge &lt; Person::Member::ValidAge::AgeRange::M=
inimum) return false;<br>&nbsp;if (person.ValidAge &gt; Person::Member::Val=
idAge::AgeRange::Maximum) return false;<br>&nbsp;return true;<br>}</div><di=
v><br></div><div>bool RegisterPerson(Person &amp;person) {&nbsp;<br>&nbsp;i=
f (!CanRegisterPerson(person)) {<br>&nbsp;&nbsp;printf("Cannot register per=
son %s:%s, %s:%s because age %d must be in between %d and %d\n"<br>&nbsp;&n=
bsp;&nbsp;,person::Member::FirstName::MyAttribute::Name.c_str()<br>&nbsp;&n=
bsp;&nbsp;,person.FistName.c_str()<br>&nbsp;&nbsp;&nbsp;,person::Member::La=
stName::MyAttribute::Name.c_str()<br>&nbsp;&nbsp;&nbsp;,person.LastName.c_s=
tr()&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;,person.Age<br>&nbsp;&nbsp;&nbs=
p;,Person::Member::ValidAge::AgeRange::Minimum<br>&nbsp;&nbsp;&nbsp;,Person=
::Member::ValidAge::AgeRange::Maximum<br>&nbsp;&nbsp;&nbsp;return false;<br=
>&nbsp;&nbsp;);<br>&nbsp;&nbsp;return true;&nbsp;&nbsp;<br>&nbsp;}</div><di=
v>}</div><div><br></div><div><br></div><div><br></div><div>On Wednesday, Ap=
ril 30, 2014 8:59:51 AM UTC-4, gmis...@gmail.com wrote:</div><blockquote cl=
ass=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; =
border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-=
style: solid;"><div dir=3D"ltr"><br>This is fun.<br>On Thursday, May 1, 201=
4 12:13:44 AM UTC+12, Klaim - Jo=C3=ABl Lamotte wrote:<blockquote class=3D"=
gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-=
left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: =
solid;"><div dir=3D"ltr">C++11 already have&nbsp;=E2=80=8Battributes. See:&=
nbsp;<a onmousedown=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2=
F%2Fen.cppreference.com%2Fw%2Fcpp%2Flanguage%2Fattributes\46sa\75D\46sntz\0=
751\46usg\75AFQjCNH9Dk3GSNX7l_TUTRgP10mO8NSFVQ';return true;" onclick=3D"th=
is.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fen.cppreference.com%2=
Fw%2Fcpp%2Flanguage%2Fattributes\46sa\75D\46sntz\0751\46usg\75AFQjCNH9Dk3GS=
NX7l_TUTRgP10mO8NSFVQ';return true;" href=3D"http://en.cppreference.com/w/c=
pp/language/attributes" target=3D"_blank">en.cppreference.com/w/<wbr>cpp/la=
nguage/attributes</a></div></blockquote><div>Yes sadly, it's true.&nbsp;</d=
iv></div></blockquote><blockquote class=3D"gmail_quote" style=3D"margin: 0p=
x 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); =
border-left-width: 1px; border-left-style: solid;"><div dir=3D"ltr"><div>&n=
bsp;</div><blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.=
8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-=
width: 1px; border-left-style: solid;"><div dir=3D"ltr"><div>Or are you sug=
gesting specific attributes to be standardised?<div>
If yes, then your example is not clear at all to me.</div><div><br></div></=
div></div></blockquote><div>I'd quite like to see&nbsp;[[warn_unused_result=
]] become standard.</div><div><a onmousedown=3D"this.href=3D'http://www.goo=
gle.com/url?q\75http%3A%2F%2Fstackoverflow.com%2Fquestions%2F2042780%2Fhow-=
to-raise-warning-if-return-value-is-disregarded-gcc-or-static-code-check\46=
sa\75D\46sntz\0751\46usg\75AFQjCNGYZ5htWBjGw25kKD3kPRdRZYT69Q';return true;=
" onclick=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fstacko=
verflow.com%2Fquestions%2F2042780%2Fhow-to-raise-warning-if-return-value-is=
-disregarded-gcc-or-static-code-check\46sa\75D\46sntz\0751\46usg\75AFQjCNGY=
Z5htWBjGw25kKD3kPRdRZYT69Q';return true;" href=3D"http://stackoverflow.com/=
questions/2042780/how-to-raise-warning-if-return-value-is-disregarded-gcc-o=
r-static-code-check" target=3D"_blank">http://stackoverflow.com/<wbr>questi=
ons/2042780/how-to-<wbr>raise-warning-if-return-value-<wbr>is-disregarded-g=
cc-or-static-<wbr>code-check</a></div><div><br></div><div>btw. anyone think=
 we're&nbsp;ready to add things like [[unused_arg]] yet?</div><div><br></di=
v><div>Thanks</div></div></blockquote></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 />

------=_Part_1384_8877558.1398875910719--

.
