220 10450 <2c2e3d6c-c1d1-4ed3-9c78-d74ec5f70c4f@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:45:28 -0700 (PDT)
Lines: 158
Approved: news@gmane.org
Message-ID: <2c2e3d6c-c1d1-4ed3-9c78-d74ec5f70c4f@isocpp.org>
References: <e9533cfc-f35c-4313-aaaf-a6d3d8aa00f9@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_162_29231422.1398876328816"
X-Trace: ger.gmane.org 1398876340 23055 80.91.229.3 (30 Apr 2014 16:45:40 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 30 Apr 2014 16:45:40 +0000 (UTC)
Cc: maksimpustovoyt@gmail.com
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCRP3Q4MT4MRBKORQSNQKGQE5S6ZZCY@isocpp.org Wed Apr 30 18:45:32 2014
Return-path: <std-proposals+bncBCRP3Q4MT4MRBKORQSNQKGQE5S6ZZCY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vc0-f199.google.com ([209.85.220.199])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCRP3Q4MT4MRBKORQSNQKGQE5S6ZZCY@isocpp.org>)
	id 1WfXdS-0007Fp-R9
	for gclcip-std-proposals@m.gmane.org; Wed, 30 Apr 2014 18:45:31 +0200
Original-Received: by mail-vc0-f199.google.com with SMTP id hq16sf6376847vcb.2
        for <gclcip-std-proposals@m.gmane.org>; Wed, 30 Apr 2014 09:45:30 -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=DrKL1R1KCBKqp1xkBr/hgpF47YldnxR3tnPaGFUNlPo=;
        b=u5H4aE6RzHkMBGjF85Kywm1lXEzRNeI6MjEhtR4sq1O/8/inRKrQlfRNTUsf3sXrux
         Q/cMXWb3xZ+fxFTKz027n/rx4sYTTesmdBsAFmUt/0dXw2Tq2oMRtgOy76uMR1hiuQrK
         35a/fpwj6zpo4u8qNyarCejQU3e3qf90SgFpQxegFf68iMZtit8Hf70OyXBPbvclTjsY
         uFb0nXDs3EI1cZLOuCVAaWzzHnscwyzZArtGUq0R3jOE/sQmKDTTyyi4cT/dqBTi+r4D
         F2qeeLgv8QeZo/xre9E2qiPWgy6R3sSFJrt5UhkFQh9PR+Nkqcn568e0GrmO1FZ/Fapp
         2oLg==
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=DrKL1R1KCBKqp1xkBr/hgpF47YldnxR3tnPaGFUNlPo=;
        b=c2Pt0ce8dIEPUHSfGdACzMkpIxJ80fBNlHdtvzDUFUaK57cf4YnGd1YaRTXsCDBVxy
         Q60/5ovlg9DZnYevuF4c3RsVfAjNYvvZhKnlp26mKBuLHYXUnasl65D5Rlc3A1RlR03w
         mW8gA5VXu8BywUdsqmB7Qn4ZAqfx3DhrIkxzo2vlztF+JjEJFt2vpp61EXeD5LR6xt9W
         fCIqNnhgx/0p1Qvlx4SxcEO6XWAZAVozlWP/cAvyRY+aKftC5dv/r2rsNkjMEB/mpzOy
         iOfgf8GX7Cw8Er5wMcysHMf5CbpjhA7gvQjDcQ4JWa+qGJS8uWXb693pirvjUzMCU1WT
         Ikmw==
X-Gm-Message-State: ALoCoQlSKiHLJduGgs7tf3oEjR93c/frEPOlBRWxwYBXXFlXdS9/UwKERC5gN3OVF3kCHpj6vKW/
X-Received: by 10.58.195.202 with SMTP id ig10mr2999333vec.38.1398876330076;
        Wed, 30 Apr 2014 09:45:30 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.182.227.230 with SMTP id sd6ls312054obc.64.gmail; Wed, 30 Apr
 2014 09:45:29 -0700 (PDT)
X-Received: by 10.182.220.197 with SMTP id py5mr37751obc.11.1398876329230;
        Wed, 30 Apr 2014 09:45:29 -0700 (PDT)
In-Reply-To: <e9533cfc-f35c-4313-aaaf-a6d3d8aa00f9@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:10450
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/10450>

------=_Part_162_29231422.1398876328816
Content-Type: text/plain; charset=UTF-8



CORRECTED SOME TYPO FROM PREVIOSE POST


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 
like that:

[AttributeExtension] // This predefine Attribute telling compiler that this 
class can be used as Attribute for other classes:
struct MyAttribute {
    string Name;
    string Description;
    MyAttribute(string name; string description= "") : Name(name), 
Description(description) {}
}
[AttributeExtension] // This predefine Attribute telling compiler that this 
class can be used as Attribute for other classes:
struct AgeRange { 
    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", "Person Info")] // called 
MyAttribute::MyAttribute("Person", "Person Info")
struct Person {
 [MyAttribute("Fist Name")] // called MyAttribute::MyAttribute("Fist Name")
 string FirstName;
 [MyAttribute("Last Name", "Person's last name")] // called 
MyAttribute::MyAttribute("Last Name", "Person's last name") 
 string LastName;
 [AgeRange(18,50)] // called AgeRange::AgeRange(18,50) 
 int ValidAge;
}


.... some time later in code...

bool CanRegisterPerson(Person &person) { 
 if (person.ValidAge < Person::Member::ValidAge::AgeRange::Minimum) return 
false; // 
 if (person.ValidAge > Person::Member::ValidAge::AgeRange::Maximum) return 
false;
 return true;
}

bool RegisterPerson(Person &person) { 
 if (!CanRegisterPerson(person)) {
  printf("Cannot register person %s:%s, %s:%s because age %d must be in 
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()   
   ,person.Age
   ,Person::Member::ValidAge::AgeRange::Minimum
   ,Person::Member::ValidAge::AgeRange::Maximum
   return false;
  );
  return true;  
 }

}

>
>
>
>
>
>

-- 

--- 
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/.

------=_Part_162_29231422.1398876328816
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><br></div><div><br></div><div>CORRECTED SOME TYPO FRO=
M PREVIOSE POST</div><p><br>This is different than C++11 attributes.</p><p>=
This is extendable Metadata about class which you can use in real time.</p>=
<p>For example, I want to print my object in nice format. I can do somethin=
g like that:</p><p>[AttributeExtension] <font color=3D"#38761d">// This pre=
define Attribute telling compiler that this class can be used as Attribute =
for other classes:</font><br>struct MyAttribute {<br>&nbsp;&nbsp;&nbsp; str=
ing Name;<br>&nbsp;&nbsp;&nbsp; string Description;<br>&nbsp;&nbsp;&nbsp; M=
yAttribute(string name; string description=3D "") : Name(name), Description=
(description) {}<br>}<br>[AttributeExtension] <font color=3D"#38761d">// Th=
is predefine Attribute telling compiler that this class can be used as Attr=
ibute for other classes:</font><br>struct AgeRange {&nbsp;<br>&nbsp;&nbsp;&=
nbsp; int Minum;<br>&nbsp;int Maximum;<br>&nbsp;AgeRange(int minum; int max=
imum)&nbsp; Minum(minum), Maximum(maximum) {}<br>}</p><p><br></p><div><font=
 color=3D"#134f5c">... some time later in code...</font></div><div><font co=
lor=3D"#134f5c"></font><br>[METADATA(true)] <font color=3D"#38761d">// tell=
s compiler to geneate meta data about my class</font><br>[MyAttribute("Pers=
on", "Person Info")] <font color=3D"#6aa84f">// called MyAttribute::MyAttri=
bute("Person", "Person Info")</font><br>struct Person {<br>&nbsp;[MyAttribu=
te("Fist Name")] <font color=3D"#6aa84f">// called MyAttribute::MyAttribute=
("Fist Name")</font><br>&nbsp;string FirstName;<br>&nbsp;[MyAttribute("Last=
 Name", "Person's last name")] <font color=3D"#6aa84f">// called MyAttribut=
e::MyAttribute("Last Name", "Person's last name")</font>&nbsp;<br>&nbsp;str=
ing LastName;<br>&nbsp;[AgeRange(18,50)]<font color=3D"#38761d"> // called =
AgeRange::AgeRange(18,50)</font>&nbsp;<br>&nbsp;int ValidAge;<br>}</div><p>=
<br>... some time later in code...</p><p>bool CanRegisterPerson(Person &amp=
;person) {&nbsp;<br>&nbsp;if (person.ValidAge &lt; Person::Member::ValidAge=
::AgeRange::Minimum) return false;&nbsp;// <br>&nbsp;if (person.ValidAge &g=
t; Person::Member::ValidAge::AgeRange::Maximum) return false;<br>&nbsp;retu=
rn true;<br>}</p><p>bool RegisterPerson(Person &amp;person) {&nbsp;<br>&nbs=
p;if (!CanRegisterPerson(person)) {<br>&nbsp;&nbsp;printf("Cannot register =
person %s:%s, %s:%s because age %d must be in between %d and %d\n"<br>&nbsp=
;&nbsp;&nbsp;,person::Member::FirstName::MyAttribute::Name.c_str()<br>&nbsp=
;&nbsp;&nbsp;,person.FistName.c_str()<br>&nbsp;&nbsp;&nbsp;,person::Member:=
:LastName::MyAttribute::Name.c_str()<br>&nbsp;&nbsp;&nbsp;,person.LastName.=
c_str()&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;,person.Age<br>&nbsp;&nbsp;&=
nbsp;,Person::Member::ValidAge::AgeRange::Minimum<br>&nbsp;&nbsp;&nbsp;,Per=
son::Member::ValidAge::AgeRange::Maximum<br>&nbsp;&nbsp;&nbsp;return false;=
<br>&nbsp;&nbsp;);<br>&nbsp;&nbsp;return true;&nbsp;&nbsp;<br>&nbsp;}</p><p=
>}<br></p><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><br></div><div=
><br></div><div><br></div><div><br></div><div><br></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_162_29231422.1398876328816--

.
