220 14334 <7e589557-cb3c-4323-9565-e6b859df0e76@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Myriachan <myriachan@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Visual C++'s __identifier keyword
Date: Thu, 30 Oct 2014 12:52:10 -0700 (PDT)
Lines: 192
Approved: news@gmane.org
Message-ID: <7e589557-cb3c-4323-9565-e6b859df0e76@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_420_1015641013.1414698730942"
X-Trace: ger.gmane.org 1414698744 26684 80.91.229.3 (30 Oct 2014 19:52:24 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 30 Oct 2014 19:52:24 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDKLT4PURQHRB3FNZKRAKGQE2US62TY@isocpp.org Thu Oct 30 20:52:16 2014
Return-path: <std-proposals+bncBDKLT4PURQHRB3FNZKRAKGQE2US62TY@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+bncBDKLT4PURQHRB3FNZKRAKGQE2US62TY@isocpp.org>)
	id 1XjvlV-0001YT-Tu
	for gclcip-std-proposals@m.gmane.org; Thu, 30 Oct 2014 20:52:14 +0100
Original-Received: by mail-vc0-f199.google.com with SMTP id le20sf8145744vcb.6
        for <gclcip-std-proposals@m.gmane.org>; Thu, 30 Oct 2014 12:52:13 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        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:content-type;
        bh=qkNV6GLXAMRpD4/AArdP2rmMa6gb+XAGcRpnemurU2s=;
        b=Sz93cU+PL+xuErVetEXSEEQaLqDJ0Jb1jtrP/5QHdM5bXqs87GJwwV8gvqajpCh6Xn
         jWA9n5UewnRRW/XkgzEvptWyPqfWCEn0sz6NWG04MKRcQl7NlETjiDLF0k8SUHDU43hA
         DQQILarQFxSJWeHpRzbnwzRi1680BA60Z5tT+N3UvkSU0h+0Qr/JVLKJZ2K1vpcqdAmW
         a9nxZImM9OqUsXi6RIjIIFnzg8JPbVNN3L/cxY9XLvL5vDcvHoLSfDVIBZht4flHSKLE
         UcdaufCuKbEObfWDH9Z2eCOOTPQJQj4QBgZWukJ4TksuJFgcshQBGMgg4mlGrqL2inLH
         ZptA==
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: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
         :content-type;
        bh=qkNV6GLXAMRpD4/AArdP2rmMa6gb+XAGcRpnemurU2s=;
        b=XBAaDPryU+qrgvY4Rl31W6Dt8y7dS6Du68uyUeG1jdGZZ9LhD1OqaOPEn8JxsI9m4M
         aj5qHm9JKUWnQ7hwlKMAe5lUZwidVbE9+702OC0e7U++LBM/ENLLM3JtKJLy0gT0/A59
         1n1JZOvoPvSgiD8CwO2o2Ue5+AVQwmaUqjugKsl1I83tMjoK8HLlLnI9Bj76NHuC4vJB
         0lCFOK3vDc+TEsPj2birtSXYuYjRP1NpxjSMHxNdUdR0sSKix233qphxcrec0ru3ZT13
         aFenR0831mPvV927H7ykDliManxkpi8XF9Iw2I8GVF2/5baneBGe/IKypOD2iVLFwXeb
         ES0g==
X-Gm-Message-State: ALoCoQlEpShoDV5N0Dxe8ihMGlVQduTabty3Awfb+t66t5vBHgiapcSmPkhk8fqgwOA1KdiW6uO4
X-Received: by 10.236.209.194 with SMTP id s42mr7789075yho.42.1414698733066;
        Thu, 30 Oct 2014 12:52:13 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.50.141.196 with SMTP id rq4ls966163igb.12.gmail; Thu, 30 Oct
 2014 12:52:12 -0700 (PDT)
X-Received: by 10.50.78.135 with SMTP id b7mr335209igx.14.1414698732483;
        Thu, 30 Oct 2014 12:52:12 -0700 (PDT)
X-Original-Sender: myriachan@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: <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:14334
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/14334>

------=_Part_420_1015641013.1414698730942
Content-Type: text/plain; charset=UTF-8

I think Visual Studio's __identifier keyword is really nice: it allows 
using keywords as identifiers.  This is useful in interoperability.  For 
example, if you had this in a .c file:

int class;

You could then do this from a .cpp file to access it:

extern "C" int __identifier(class);

__identifier also may take a literal string as a parameter, allowing weird 
characters in identifiers.  I would say that the effect of using a literal 
string that is neither a legal C++ identifier nor a C++ keyword (i.e. 
something that'd work without being a string) has unspecified behavior, 
leaving it to the implementation to decide whether such a thing is 
meaningful or an error.  This literal string feature can be used to access 
mangled symbol names if used in conjunction with extern "C", or could be 
used to put dollar signs in identifiers.  And yes, 
__identifier(__identifier) is legal.


There is actually an interesting secondary use for __identifier: detecting 
whether a type is native.  For example, this will return true whenever 
Microsoft gets around to implementing char16_t for real:

class _is_wchar_t_native_helper
{
    struct dummy;
    typedef dummy *__identifier(wchar_t);
    struct inner
    {
        typedef wchar_t direct;
    };
    friend struct is_wchar_t_native;
};

struct is_wchar_t_native
    : std::integral_constant<bool, !std::is_same<
        _is_wchar_t_native_helper::inner::direct,
        _is_wchar_t_native_helper::__identifier(wchar_t)>::value>
{
};

Of course, I wouldn't call it "__identifier".  Maybe _Identifier, if we 
could get C on board.  Assuming that this proposal isn't hated =)

Melissa

-- 

--- 
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_420_1015641013.1414698730942
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I think Visual Studio's __identifier keyword is really nic=
e: it allows using keywords as identifiers.&nbsp; This is useful in interop=
erability.&nbsp; For example, if you had this in a .c file:<br><br><div cla=
ss=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border-co=
lor: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wrap:=
 break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">class</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br></span></div></code></div><br>You could then d=
o this from a .cpp file to access it:<br><br><div class=3D"prettyprint" sty=
le=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187=
); border-style: solid; border-width: 1px; word-wrap: break-word;"><code cl=
ass=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">extern</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=3D"=
styled-by-prettify">"C"</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> __=
identifier</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">class</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div></cod=
e></div><br>__identifier also may take a literal string as a parameter, all=
owing weird characters in identifiers.&nbsp; I would say that the effect of=
 using a literal string that is neither a legal C++ identifier nor a C++ ke=
yword (i.e. something that'd work without being a string) has unspecified b=
ehavior, leaving it to the implementation to decide whether such a thing is=
 meaningful or an error.&nbsp; This literal string feature can be used to a=
ccess mangled symbol names if used in conjunction with extern "C", or could=
 be used to put dollar signs in identifiers.&nbsp; And yes, __identifier(__=
identifier) is legal.<br><br><br>There is actually an interesting secondary=
 use for __identifier: detecting whether a type is native.&nbsp; For exampl=
e, this will return true whenever Microsoft gets around to implementing cha=
r16_t for real:<br><br><div class=3D"prettyprint" style=3D"background-color=
: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid=
; border-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><d=
iv class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by=
-prettify">class</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> _is_wchar_t_native_helper<br></span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">struct</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> dummy</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">typedef</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> dummy </span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">*</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>__identifier</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">wchar_=
t</span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp;=
 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">struct</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> inner<br>&nb=
sp; &nbsp; </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbs=
p; &nbsp; &nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styled=
-by-prettify">typedef</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">wchar_t</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
direct</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &n=
bsp; </span><span style=3D"color: #660;" class=3D"styled-by-prettify">};</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &n=
bsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">frien=
d</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">struct</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> is_wchar_t_native</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">};</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br><br></span><span style=3D"color:=
 #008;" class=3D"styled-by-prettify">struct</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> is_wchar_t_native<br>&nbsp; &nbsp; </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify">integral_constant</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color:=
 #008;" class=3D"styled-by-prettify">bool</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: #660;" class=3D"style=
d-by-prettify">!</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify">std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">:=
:</span><span style=3D"color: #000;" class=3D"styled-by-prettify">is_same</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; =
&nbsp; &nbsp; _is_wchar_t_native_helper</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">inner</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify">direct</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&=
nbsp; &nbsp; &nbsp; &nbsp; _is_wchar_t_native_helper</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify">__identifier</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">wchar_t</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">)&gt;::</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">value</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">};</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div></=
code></div><br>Of course, I wouldn't call it "__identifier".&nbsp; Maybe _I=
dentifier, if we could get C on board.&nbsp; Assuming that this proposal is=
n't hated =3D)<br><br>Melissa<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">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_420_1015641013.1414698730942--

.
