Topic: Custom function names for external linkage with


Author: paulo_torrens@ekolivre.com.br
Date: Thu, 17 Oct 2013 11:19:38 -0700 (PDT)
Raw View
------=_Part_440_14047567.1382033978702
Content-Type: text/plain; charset=ISO-8859-1

Hello there,

I am working on a compiler suite which should support many programming
languages. Since C++ supports external linkage specifying the source
language, I intend to use C++ as a "bridge language" across programming
languages when needed.

A problem arrives when, for example, I need access to a method name which
uses symbols that can't appear on a C++ identifier.

Let's get an example, the Objective-C language (this could replace the ugly
Objective-C++):

*extern* *"Objective-C"* *{*
  *class* NSObject *{*
    *public:*
      *static* NSObject ***alloc*();*
      NSObject ***init*();*
  *};*
*};*

*// The C++ compiler should emit the the same code that the ObjC compiler
would for [[NSObject alloc] init]*
NSObject ***obj = NSObject*::*alloc*()->*init*();*

Which is a fair example, and could work as it is. But... and for method
like "initWith:And:", which uses the colons to specify it takes two
arguments. As of the current standard, I can't specify such methods.

Has anyone though of it yet? Was any proposal already offered to solve this
possible issue?

There are two things that come to my mind: first and obvious is to use the
[Attributes] from C++11. What attribute should specify the names, then?
The second thing would be to extend the syntax in order to accept string
literals as identifiers as well.

*extern* *"Common Lisp"* *{*
  *class* *"|My Class|"* *{*
    *public**:*
      *int* *"myv@r"**;*
      *void* ****"didStuff?"**(**int**);*
  *};*
  *void* *"some-random-function"();*
*};*

*"|My Class|"* ***x *=* *new* *"|My Class|"**;*
*void* ***y *=* x*->**"didStuff?"**(*42*);*
cout *<<* x*->**"myv@r"* *<<* endl;
*"some-random-function"();*


What do you guys think? Anyone has another idea?

After implementing this behaviour on my compiler, I intend to propose this
extension to the standard.

--

---
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_440_14047567.1382033978702
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hello there,<br><br>I am working on a compiler suite which=
 should support many programming languages. Since C++ supports external lin=
kage specifying the source language, I intend to use C++ as a "bridge langu=
age" across programming languages when needed.<br><br>A problem arrives whe=
n, for example, I need access to a method name which uses symbols that can'=
t appear on a C++ identifier.<br><br>Let's get an example, the Objective-C =
language (this could replace the ugly Objective-C++):<br><br><div style=3D"=
margin-left: 40px;"><span style=3D"font-family: courier new,monospace;"><sp=
an style=3D"color: rgb(0, 0, 255);"><b>extern</b></span> <span style=3D"col=
or: rgb(153, 0, 255);"><b>"Objective-C"</b></span> <b>{</b></span><br><span=
 style=3D"font-family: courier new,monospace;">&nbsp; <b><span style=3D"col=
or: rgb(0, 0, 255);">class</span></b> NSObject <b>{</b></span><br><span sty=
le=3D"font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; <b><span styl=
e=3D"color: rgb(0, 0, 255);">public</span>:</b></span><br><span style=3D"fo=
nt-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span sty=
le=3D"color: rgb(0, 0, 255);"><b>static</b></span> NSObject <b>*</b>alloc<b=
>();</b></span><br><span style=3D"font-family: courier new,monospace;">&nbs=
p;&nbsp; &nbsp;&nbsp; NSObject <b>*</b>init<b>();</b></span><br><span style=
=3D"font-family: courier new,monospace;">&nbsp; <b>};</b></span><br><b><spa=
n style=3D"font-family: courier new,monospace;">};</span></b><br><span styl=
e=3D"font-family: courier new,monospace;"></span><br><span style=3D"color: =
rgb(56, 118, 29);"><i><span style=3D"font-family: courier new,monospace;">/=
/ The C++ compiler should emit the the same code that the ObjC compiler wou=
ld for [[NSObject alloc] init]</span></i></span><br><span style=3D"font-fam=
ily: courier new,monospace;">NSObject <b>*</b>obj =3D NSObject<b>::</b>allo=
c<b>()-&gt;</b>init<b>();</b></span><br></div><br>Which is a fair example, =
and could work as it is. But... and for method like "initWith:And:", which =
uses the colons to specify it takes two arguments. As of the current standa=
rd, I can't specify such methods.<br><br>Has anyone though of it yet? Was a=
ny proposal already offered to solve this possible issue?<br><br>There are =
two things that come to my mind: first and obvious is to use the [Attribute=
s] from C++11. What attribute should specify the names, then?<br>The second=
 thing would be to extend the syntax in order to accept string literals as =
identifiers as well.<br><br><div style=3D"margin-left: 40px;"><span style=
=3D"font-family: courier new,monospace;"><b><span style=3D"color: rgb(0, 0,=
 255);">extern</span></b> <span style=3D"background-color: rgb(255, 255, 25=
5);"><span style=3D"color: rgb(153, 0, 255);"><b>"Common Lisp"</b></span></=
span> <b>{</b><br>&nbsp; <span style=3D"color: rgb(0, 0, 255);"><b>class</b=
></span> <span style=3D"color: rgb(153, 0, 255);"><b>"|My Class|"</b></span=
> <b>{</b><br>&nbsp;&nbsp;&nbsp; <span style=3D"color: rgb(0, 0, 255);"><b>=
public</b></span><b>:</b><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=3D"=
color: rgb(0, 0, 255);"><b>int</b></span> <span style=3D"color: rgb(153, 0,=
 255);"><b>"myv@r"</b></span><b>;</b><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <sp=
an style=3D"color: rgb(0, 0, 255);"><b>void</b></span> <b>*</b><span style=
=3D"color: rgb(153, 0, 255);"><b>"didStuff?"</b></span><b>(</b><span style=
=3D"color: rgb(0, 0, 255);"><b>int</b></span><b>);</b><br>&nbsp; <b>};</b><=
br>&nbsp; <b><span style=3D"color: rgb(0, 0, 255);">void</span></b> <b><spa=
n style=3D"color: rgb(153, 0, 255);">"some-random-function"</span>();</b><b=
r><b>};</b><br><br><b><span style=3D"color: rgb(153, 0, 255);">"|My Class|"=
</span></b> <b>*</b>x <b>=3D</b> <span style=3D"color: rgb(0, 0, 255);"><b>=
new</b></span> <span style=3D"color: rgb(153, 0, 255);"><b>"|My Class|"</b>=
</span><b>;</b><br><b><span style=3D"color: rgb(0, 0, 255);">void</span></b=
> <b>*</b>y <b>=3D</b> x<b>-&gt;</b><span style=3D"color: rgb(153, 0, 255);=
"><b>"didStuff?"</b></span><b>(</b><span style=3D"color: rgb(61, 133, 198);=
">42</span><b>);</b><br>cout <b>&lt;&lt;</b> x<b>-&gt;</b><span style=3D"co=
lor: rgb(153, 0, 255);"><b>"myv@r"</b></span> <b>&lt;&lt;</b> endl;<br><b><=
span style=3D"color: rgb(153, 0, 255);">"some-random-function"</span>();</b=
></span><br></div><br><br>What do you guys think? Anyone has another idea?<=
br><br>After implementing this behaviour on my compiler, I intend to propos=
e this extension to the standard.<br></div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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_440_14047567.1382033978702--

.


Author: tomalak@gmail.com
Date: Thu, 17 Oct 2013 14:16:06 -0700 (PDT)
Raw View
------=_Part_267_27438053.1382044566254
Content-Type: text/plain; charset=ISO-8859-1

I'm going to stop you right here:
>
> Since C++ supports external linkage specifying the source language

No, it doesn't.

The end.
Best regards


On Thursday, October 17, 2013 7:19:38 PM UTC+1, paulo_...@ekolivre.com.br
wrote:
>
> Hello there,
>
> I am working on a compiler suite which should support many programming
> languages. Since C++ supports external linkage specifying the source
> language, I intend to use C++ as a "bridge language" across programming
> languages when needed.
>
> A problem arrives when, for example, I need access to a method name which
> uses symbols that can't appear on a C++ identifier.
>
> Let's get an example, the Objective-C language (this could replace the
> ugly Objective-C++):
>
> *extern* *"Objective-C"* *{*
>   *class* NSObject *{*
>     *public:*
>       *static* NSObject ***alloc*();*
>       NSObject ***init*();*
>   *};*
> *};*
>
> *// The C++ compiler should emit the the same code that the ObjC compiler
> would for [[NSObject alloc] init]*
> NSObject ***obj = NSObject*::*alloc*()->*init*();*
>
> Which is a fair example, and could work as it is. But... and for method
> like "initWith:And:", which uses the colons to specify it takes two
> arguments. As of the current standard, I can't specify such methods.
>
> Has anyone though of it yet? Was any proposal already offered to solve
> this possible issue?
>
> There are two things that come to my mind: first and obvious is to use the
> [Attributes] from C++11. What attribute should specify the names, then?
> The second thing would be to extend the syntax in order to accept string
> literals as identifiers as well.
>
> *extern* *"Common Lisp"* *{*
>   *class* *"|My Class|"* *{*
>     *public**:*
>       *int* *"myv@r"**;*
>       *void* ****"didStuff?"**(**int**);*
>   *};*
>   *void* *"some-random-function"();*
> *};*
>
> *"|My Class|"* ***x *=* *new* *"|My Class|"**;*
> *void* ***y *=* x*->**"didStuff?"**(*42*);*
> cout *<<* x*->**"myv@r"* *<<* endl;
> *"some-random-function"();*
>
>
> What do you guys think? Anyone has another idea?
>
> After implementing this behaviour on my compiler, I intend to propose this
> extension to the standard.
>

--

---
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_267_27438053.1382044566254
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I'm going to stop you right here:<blockquote class=3D"gmai=
l_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: 1e=
x;">Since C++ supports external linkage specifying the source language</blo=
ckquote><div>No, it doesn't.</div><div><br></div><div>The end.</div><div>Be=
st regards</div><div><br><br>On Thursday, October 17, 2013 7:19:38 PM UTC+1=
, paulo_...@ekolivre.com.br wrote:<blockquote class=3D"gmail_quote" style=
=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: =
1ex;"><div dir=3D"ltr">Hello there,<br><br>I am working on a compiler suite=
 which should support many programming languages. Since C++ supports extern=
al linkage specifying the source language, I intend to use C++ as a "bridge=
 language" across programming languages when needed.<br><br>A problem arriv=
es when, for example, I need access to a method name which uses symbols tha=
t can't appear on a C++ identifier.<br><br>Let's get an example, the Object=
ive-C language (this could replace the ugly Objective-C++):<br><br><div sty=
le=3D"margin-left:40px"><span style=3D"font-family:courier new,monospace"><=
span style=3D"color:rgb(0,0,255)"><b>extern</b></span> <span style=3D"color=
:rgb(153,0,255)"><b>"Objective-C"</b></span> <b>{</b></span><br><span style=
=3D"font-family:courier new,monospace">&nbsp; <b><span style=3D"color:rgb(0=
,0,255)">class</span></b> NSObject <b>{</b></span><br><span style=3D"font-f=
amily:courier new,monospace">&nbsp;&nbsp;&nbsp; <b><span style=3D"color:rgb=
(0,0,255)">public</span>:</b></span><br><span style=3D"font-family:courier =
new,monospace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=3D"color:rgb(0,0,=
255)"><b>static</b></span> NSObject <b>*</b>alloc<b>();</b></span><br><span=
 style=3D"font-family:courier new,monospace">&nbsp;&nbsp; &nbsp;&nbsp; NSOb=
ject <b>*</b>init<b>();</b></span><br><span style=3D"font-family:courier ne=
w,monospace">&nbsp; <b>};</b></span><br><b><span style=3D"font-family:couri=
er new,monospace">};</span></b><br><span style=3D"font-family:courier new,m=
onospace"></span><br><span style=3D"color:rgb(56,118,29)"><i><span style=3D=
"font-family:courier new,monospace">// The C++ compiler should emit the the=
 same code that the ObjC compiler would for [[NSObject alloc] init]</span><=
/i></span><br><span style=3D"font-family:courier new,monospace">NSObject <b=
>*</b>obj =3D NSObject<b>::</b>alloc<b>()-&gt;</b>init<b>();</b></span><br>=
</div><br>Which is a fair example, and could work as it is. But... and for =
method like "initWith:And:", which uses the colons to specify it takes two =
arguments. As of the current standard, I can't specify such methods.<br><br=
>Has anyone though of it yet? Was any proposal already offered to solve thi=
s possible issue?<br><br>There are two things that come to my mind: first a=
nd obvious is to use the [Attributes] from C++11. What attribute should spe=
cify the names, then?<br>The second thing would be to extend the syntax in =
order to accept string literals as identifiers as well.<br><br><div style=
=3D"margin-left:40px"><span style=3D"font-family:courier new,monospace"><b>=
<span style=3D"color:rgb(0,0,255)">extern</span></b> <span style=3D"backgro=
und-color:rgb(255,255,255)"><span style=3D"color:rgb(153,0,255)"><b>"Common=
 Lisp"</b></span></span> <b>{</b><br>&nbsp; <span style=3D"color:rgb(0,0,25=
5)"><b>class</b></span> <span style=3D"color:rgb(153,0,255)"><b>"|My Class|=
"</b></span> <b>{</b><br>&nbsp;&nbsp;&nbsp; <span style=3D"color:rgb(0,0,25=
5)"><b>public</b></span><b>:</b><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span st=
yle=3D"color:rgb(0,0,255)"><b>int</b></span> <span style=3D"color:rgb(153,0=
,255)"><b>"myv@r"</b></span><b>;</b><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <spa=
n style=3D"color:rgb(0,0,255)"><b>void</b></span> <b>*</b><span style=3D"co=
lor:rgb(153,0,255)"><b>"didStuff?"</b></span><b>(</b><span style=3D"color:r=
gb(0,0,255)"><b>int</b></span><b>);</b><br>&nbsp; <b>};</b><br>&nbsp; <b><s=
pan style=3D"color:rgb(0,0,255)">void</span></b> <b><span style=3D"color:rg=
b(153,0,255)">"some-random-function"</span>();</b><br><b>};</b><br><br><b><=
span style=3D"color:rgb(153,0,255)">"|My Class|"</span></b> <b>*</b>x <b>=
=3D</b> <span style=3D"color:rgb(0,0,255)"><b>new</b></span> <span style=3D=
"color:rgb(153,0,255)"><b>"|My Class|"</b></span><b>;</b><br><b><span style=
=3D"color:rgb(0,0,255)">void</span></b> <b>*</b>y <b>=3D</b> x<b>-&gt;</b><=
span style=3D"color:rgb(153,0,255)"><b>"didStuff?"</b></span><b>(</b><span =
style=3D"color:rgb(61,133,198)">42</span><b>);</b><br>cout <b>&lt;&lt;</b> =
x<b>-&gt;</b><span style=3D"color:rgb(153,0,255)"><b>"myv@r"</b></span> <b>=
&lt;&lt;</b> endl;<br><b><span style=3D"color:rgb(153,0,255)">"some-random-=
function"</span>();</b></span><br></div><br><br>What do you guys think? Any=
one has another idea?<br><br>After implementing this behaviour on my compil=
er, I intend to propose this extension to the standard.<br></div></blockquo=
te></div></div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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_267_27438053.1382044566254--

.


Author: Richard Smith <richard@metafoo.co.uk>
Date: Thu, 17 Oct 2013 14:20:17 -0700
Raw View
--047d7bd910de6f807604e8f662eb
Content-Type: text/plain; charset=ISO-8859-1

On Thu, Oct 17, 2013 at 11:19 AM, <paulo_torrens@ekolivre.com.br> wrote:

> Hello there,
>
> I am working on a compiler suite which should support many programming
> languages. Since C++ supports external linkage specifying the source
> language, I intend to use C++ as a "bridge language" across programming
> languages when needed.
>
> A problem arrives when, for example, I need access to a method name which
> uses symbols that can't appear on a C++ identifier.
>
> Let's get an example, the Objective-C language (this could replace the
> ugly Objective-C++):
>
> *extern* *"Objective-C"* *{*
>   *class* NSObject *{*
>     *public:*
>       *static* NSObject ***alloc*();*
>       NSObject ***init*();*
>   *};*
> *};*
>
> *// The C++ compiler should emit the the same code that the ObjC compiler
> would for [[NSObject alloc] init]*
> NSObject ***obj = NSObject*::*alloc*()->*init*();*
>
> Which is a fair example, and could work as it is. But... and for method
> like "initWith:And:", which uses the colons to specify it takes two
> arguments. As of the current standard, I can't specify such methods.
>
> Has anyone though of it yet? Was any proposal already offered to solve
> this possible issue?
>
> There are two things that come to my mind: first and obvious is to use the
> [Attributes] from C++11. What attribute should specify the names, then?
> The second thing would be to extend the syntax in order to accept string
> literals as identifiers as well.
>
> *extern* *"Common Lisp"* *{*
>   *class* *"|My Class|"* *{*
>     *public**:*
>       *int* *"myv@r"**;*
>       *void* ****"didStuff?"**(**int**);*
>   *};*
>   *void* *"some-random-function"();*
> *};*
>
> *"|My Class|"* ***x *=* *new* *"|My Class|"**;*
> *void* ***y *=* x*->**"didStuff?"**(*42*);*
> cout *<<* x*->**"myv@r"* *<<* endl;
> *"some-random-function"();*
>
>
> What do you guys think? Anyone has another idea?
>
> After implementing this behaviour on my compiler, I intend to propose this
> extension to the standard.
>

It's not obvious to me why the standard would need to say anything about
this. Once you see 'extern X' where X is not "C" or "C++", the semantics
are implementation-defined, and once you're relying on a particular
implementation's extensions, you can use whatever syntax the implementation
provides.

--

---
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/.

--047d7bd910de6f807604e8f662eb
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Thu, Oct 17, 2013 at 11:19 AM,  <span dir=3D"ltr">&lt;<=
a href=3D"mailto:paulo_torrens@ekolivre.com.br" target=3D"_blank">paulo_tor=
rens@ekolivre.com.br</a>&gt;</span> wrote:<br><div class=3D"gmail_extra"><d=
iv class=3D"gmail_quote">
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr">Hello there,<br><br>I am wo=
rking on a compiler suite which should support many programming languages. =
Since C++ supports external linkage specifying the source language, I inten=
d to use C++ as a &quot;bridge language&quot; across programming languages =
when needed.<br>
<br>A problem arrives when, for example, I need access to a method name whi=
ch uses symbols that can&#39;t appear on a C++ identifier.<br><br>Let&#39;s=
 get an example, the Objective-C language (this could replace the ugly Obje=
ctive-C++):<br>
<br><div style=3D"margin-left:40px"><span style=3D"font-family:courier new,=
monospace"><span style=3D"color:rgb(0,0,255)"><b>extern</b></span> <span st=
yle=3D"color:rgb(153,0,255)"><b>&quot;Objective-C&quot;</b></span> <b>{</b>=
</span><br>
<span style=3D"font-family:courier new,monospace">=A0 <b><span style=3D"col=
or:rgb(0,0,255)">class</span></b> NSObject <b>{</b></span><br><span style=
=3D"font-family:courier new,monospace">=A0=A0=A0 <b><span style=3D"color:rg=
b(0,0,255)">public</span>:</b></span><br>
<span style=3D"font-family:courier new,monospace">=A0=A0=A0=A0=A0 <span sty=
le=3D"color:rgb(0,0,255)"><b>static</b></span> NSObject <b>*</b>alloc<b>();=
</b></span><br><span style=3D"font-family:courier new,monospace">=A0=A0 =A0=
=A0 NSObject <b>*</b>init<b>();</b></span><br>
<span style=3D"font-family:courier new,monospace">=A0 <b>};</b></span><br><=
b><span style=3D"font-family:courier new,monospace">};</span></b><br><span =
style=3D"font-family:courier new,monospace"></span><br><span style=3D"color=
:rgb(56,118,29)"><i><span style=3D"font-family:courier new,monospace">// Th=
e C++ compiler should emit the the same code that the ObjC compiler would f=
or [[NSObject alloc] init]</span></i></span><br>
<span style=3D"font-family:courier new,monospace">NSObject <b>*</b>obj =3D =
NSObject<b>::</b>alloc<b>()-&gt;</b>init<b>();</b></span><br></div><br>Whic=
h is a fair example, and could work as it is. But... and for method like &q=
uot;initWith:And:&quot;, which uses the colons to specify it takes two argu=
ments. As of the current standard, I can&#39;t specify such methods.<br>
<br>Has anyone though of it yet? Was any proposal already offered to solve =
this possible issue?<br><br>There are two things that come to my mind: firs=
t and obvious is to use the [Attributes] from C++11. What attribute should =
specify the names, then?<br>
The second thing would be to extend the syntax in order to accept string li=
terals as identifiers as well.<br><br><div style=3D"margin-left:40px"><span=
 style=3D"font-family:courier new,monospace"><b><span style=3D"color:rgb(0,=
0,255)">extern</span></b> <span style><span style=3D"color:rgb(153,0,255)">=
<b>&quot;Common Lisp&quot;</b></span></span> <b>{</b><br>
=A0 <span style=3D"color:rgb(0,0,255)"><b>class</b></span> <span style=3D"c=
olor:rgb(153,0,255)"><b>&quot;|My Class|&quot;</b></span> <b>{</b><br>=A0=
=A0=A0 <span style=3D"color:rgb(0,0,255)"><b>public</b></span><b>:</b><br>=
=A0=A0=A0=A0=A0 <span style=3D"color:rgb(0,0,255)"><b>int</b></span> <span =
style=3D"color:rgb(153,0,255)"><b>&quot;myv@r&quot;</b></span><b>;</b><br>
=A0=A0=A0=A0=A0 <span style=3D"color:rgb(0,0,255)"><b>void</b></span> <b>*<=
/b><span style=3D"color:rgb(153,0,255)"><b>&quot;didStuff?&quot;</b></span>=
<b>(</b><span style=3D"color:rgb(0,0,255)"><b>int</b></span><b>);</b><br>=
=A0 <b>};</b><br>
=A0 <b><span style=3D"color:rgb(0,0,255)">void</span></b> <b><span style=3D=
"color:rgb(153,0,255)">&quot;some-random-function&quot;</span>();</b><br><b=
>};</b><br><br><b><span style=3D"color:rgb(153,0,255)">&quot;|My Class|&quo=
t;</span></b> <b>*</b>x <b>=3D</b> <span style=3D"color:rgb(0,0,255)"><b>ne=
w</b></span> <span style=3D"color:rgb(153,0,255)"><b>&quot;|My Class|&quot;=
</b></span><b>;</b><br>
<b><span style=3D"color:rgb(0,0,255)">void</span></b> <b>*</b>y <b>=3D</b> =
x<b>-&gt;</b><span style=3D"color:rgb(153,0,255)"><b>&quot;didStuff?&quot;<=
/b></span><b>(</b><span style=3D"color:rgb(61,133,198)">42</span><b>);</b><=
br>cout <b>&lt;&lt;</b> x<b>-&gt;</b><span style=3D"color:rgb(153,0,255)"><=
b>&quot;myv@r&quot;</b></span> <b>&lt;&lt;</b> endl;<br>
<b><span style=3D"color:rgb(153,0,255)">&quot;some-random-function&quot;</s=
pan>();</b></span><br></div><br><br>What do you guys think? Anyone has anot=
her idea?<br><br>After implementing this behaviour on my compiler, I intend=
 to propose this extension to the standard.</div>
</blockquote><div><br></div><div>It&#39;s not obvious to me why the standar=
d would need to say anything about this. Once you see &#39;extern X&#39; wh=
ere X is not &quot;C&quot; or &quot;C++&quot;, the semantics are implementa=
tion-defined, and once you&#39;re relying on a particular implementation&#3=
9;s extensions, you can use whatever syntax the implementation provides.</d=
iv>
</div></div></div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />

--047d7bd910de6f807604e8f662eb--

.


Author: paulo_torrens@ekolivre.com.br
Date: Thu, 17 Oct 2013 15:20:48 -0700 (PDT)
Raw View
------=_Part_812_642478.1382048448292
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: quoted-printable

According to =A77.5/2:

Use of a *string-literal* other than "C" or "C++" is=20
conditionally-supported, with implementation-defined semantics. [ Note:=20
Therefore, a linkage-specification with a string- literal that is unknown=
=20
to the implementation requires a diagnostic. =97 end note ] [ Note: It is=
=20
recommended that the spelling of the string-literal be taken from the=20
document defining that language. For example, Ada (not ADA) and Fortran or=
=20
FORTRAN, depending on the vintage. =97 end note ]

Different semantics, same syntax. So I would need a syntax extension to=20
support it.

What I'm trying to propose is a way of handling such custom names in a=20
standard way, so no extension is needed at all (only custom semantic, as=20
allowed by the standard), meaning my implementation would still be fully=20
conformant.

That's why I'm proposing this. Even a simple a standard [[generalized=20
attribute]] would be enough, and would make an implementation supporting=20
such linkage conformant. Something like *void* initWithAnd*(int* a*,* *int*=
b
*)* *[[*name*(**"initWith:And:"**)]]*, for example.

This way the implementation would parse ok on any compiler, just would give=
=20
an error because of the invalid linkage specifier and unknown attribute; no=
=20
syntax error, though.



Em quinta-feira, 17 de outubro de 2013 18h16min06s UTC-3, tom...@gmail.com=
=20
escreveu:
>
> I'm going to stop you right here:
>>
>> Since C++ supports external linkage specifying the source language
>
> No, it doesn't.
>
> The end.
> Best regards
>
>
> On Thursday, October 17, 2013 7:19:38 PM UTC+1, paulo_...@ekolivre.com.br=
wrote:
>>
>> Hello there,
>>
>> I am working on a compiler suite which should support many programming=
=20
>> languages. Since C++ supports external linkage specifying the source=20
>> language, I intend to use C++ as a "bridge language" across programming=
=20
>> languages when needed.
>>
>> A problem arrives when, for example, I need access to a method name whic=
h=20
>> uses symbols that can't appear on a C++ identifier.
>>
>> Let's get an example, the Objective-C language (this could replace the=
=20
>> ugly Objective-C++):
>>
>> *extern* *"Objective-C"* *{*
>>   *class* NSObject *{*
>>     *public:*
>>       *static* NSObject ***alloc*();*
>>       NSObject ***init*();*
>>   *};*
>> *};*
>>
>> *// The C++ compiler should emit the the same code that the ObjC=20
>> compiler would for [[NSObject alloc] init]*
>> NSObject ***obj =3D NSObject*::*alloc*()->*init*();*
>>
>> Which is a fair example, and could work as it is. But... and for method=
=20
>> like "initWith:And:", which uses the colons to specify it takes two=20
>> arguments. As of the current standard, I can't specify such methods.
>>
>> Has anyone though of it yet? Was any proposal already offered to solve=
=20
>> this possible issue?
>>
>> There are two things that come to my mind: first and obvious is to use=
=20
>> the [Attributes] from C++11. What attribute should specify the names, th=
en?
>> The second thing would be to extend the syntax in order to accept string=
=20
>> literals as identifiers as well.
>>
>> *extern* *"Common Lisp"* *{*
>>   *class* *"|My Class|"* *{*
>>     *public**:*
>>       *int* *"myv@r"**;*
>>       *void* ****"didStuff?"**(**int**);*
>>   *};*
>>   *void* *"some-random-function"();*
>> *};*
>>
>> *"|My Class|"* ***x *=3D* *new* *"|My Class|"**;*
>> *void* ***y *=3D* x*->**"didStuff?"**(*42*);*
>> cout *<<* x*->**"myv@r"* *<<* endl;
>> *"some-random-function"();*
>>
>>
>> What do you guys think? Anyone has another idea?
>>
>> After implementing this behaviour on my compiler, I intend to propose=20
>> this extension to the standard.
>>
>

--=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_812_642478.1382048448292
Content-Type: text/html; charset=windows-1252
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">According to =A77.5/2:<br><br><div style=3D"margin-left: 4=
0px;">Use of a <em>string-literal</em> other than "C" or "C++" is=20
conditionally-supported, with implementation-defined semantics. [ Note:=20
Therefore, a linkage-specification with a string- literal that is=20
unknown to the implementation requires a diagnostic. =97 end note ] [=20
Note: It is recommended that the spelling of the string-literal be taken
 from the document defining that language. For example, Ada (not ADA)=20
and Fortran or FORTRAN, depending on the vintage. =97 end note ]</div><br>D=
ifferent semantics, same syntax. So I would need a syntax extension to supp=
ort it.<br><br>What I'm trying to propose is a way of handling such custom =
names in a standard way, so no extension is needed at all (only custom sema=
ntic, as allowed by the standard), meaning my implementation would still be=
 fully conformant.<br><br>That's why I'm proposing this. Even a simple a st=
andard [[generalized attribute]] would be enough, and would make an impleme=
ntation supporting such linkage conformant. Something like <span style=3D"f=
ont-family: courier new,monospace;"><span style=3D"color: rgb(0, 0, 255);">=
<b>void</b></span> initWithAnd<b>(<span style=3D"color: rgb(0, 0, 255);">in=
t</span></b> a<b>,</b> <span style=3D"color: rgb(0, 0, 255);"><b>int</b></s=
pan> b<b>)</b> <b>[[</b>name<b>(</b><span style=3D"color: rgb(153, 0, 255);=
"><b>"initWith:And:"</b></span><b>)]]</b></span>, for example.<br><br>This =
way the implementation would parse ok on any compiler, just would give an e=
rror because of the invalid linkage specifier and unknown attribute; no syn=
tax error, though.<br><br><br><br>Em quinta-feira, 17 de outubro de 2013 18=
h16min06s UTC-3, tom...@gmail.com  escreveu:<blockquote class=3D"gmail_quot=
e" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;paddin=
g-left: 1ex;"><div dir=3D"ltr">I'm going to stop you right here:<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">Since C++ supports external linkage specifying the source language</b=
lockquote><div>No, it doesn't.</div><div><br></div><div>The end.</div><div>=
Best regards</div><div><br><br>On Thursday, October 17, 2013 7:19:38 PM UTC=
+1, <a>paulo_...@ekolivre.com.br</a> wrote:<blockquote class=3D"gmail_quote=
" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-le=
ft:1ex"><div dir=3D"ltr">Hello there,<br><br>I am working on a compiler sui=
te which should support many programming languages. Since C++ supports exte=
rnal linkage specifying the source language, I intend to use C++ as a "brid=
ge language" across programming languages when needed.<br><br>A problem arr=
ives when, for example, I need access to a method name which uses symbols t=
hat can't appear on a C++ identifier.<br><br>Let's get an example, the Obje=
ctive-C language (this could replace the ugly Objective-C++):<br><br><div s=
tyle=3D"margin-left:40px"><span style=3D"font-family:courier new,monospace"=
><span style=3D"color:rgb(0,0,255)"><b>extern</b></span> <span style=3D"col=
or:rgb(153,0,255)"><b>"Objective-C"</b></span> <b>{</b></span><br><span sty=
le=3D"font-family:courier new,monospace">&nbsp; <b><span style=3D"color:rgb=
(0,0,255)">class</span></b> NSObject <b>{</b></span><br><span style=3D"font=
-family:courier new,monospace">&nbsp;&nbsp;&nbsp; <b><span style=3D"color:r=
gb(0,0,255)">public</span>:</b></span><br><span style=3D"font-family:courie=
r new,monospace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=3D"color:rgb(0,=
0,255)"><b>static</b></span> NSObject <b>*</b>alloc<b>();</b></span><br><sp=
an style=3D"font-family:courier new,monospace">&nbsp;&nbsp; &nbsp;&nbsp; NS=
Object <b>*</b>init<b>();</b></span><br><span style=3D"font-family:courier =
new,monospace">&nbsp; <b>};</b></span><br><b><span style=3D"font-family:cou=
rier new,monospace">};</span></b><br><span style=3D"font-family:courier new=
,monospace"></span><br><span style=3D"color:rgb(56,118,29)"><i><span style=
=3D"font-family:courier new,monospace">// The C++ compiler should emit the =
the same code that the ObjC compiler would for [[NSObject alloc] init]</spa=
n></i></span><br><span style=3D"font-family:courier new,monospace">NSObject=
 <b>*</b>obj =3D NSObject<b>::</b>alloc<b>()-&gt;</b>init<b>();</b></span><=
br></div><br>Which is a fair example, and could work as it is. But... and f=
or method like "initWith:And:", which uses the colons to specify it takes t=
wo arguments. As of the current standard, I can't specify such methods.<br>=
<br>Has anyone though of it yet? Was any proposal already offered to solve =
this possible issue?<br><br>There are two things that come to my mind: firs=
t and obvious is to use the [Attributes] from C++11. What attribute should =
specify the names, then?<br>The second thing would be to extend the syntax =
in order to accept string literals as identifiers as well.<br><br><div styl=
e=3D"margin-left:40px"><span style=3D"font-family:courier new,monospace"><b=
><span style=3D"color:rgb(0,0,255)">extern</span></b> <span style=3D"backgr=
ound-color:rgb(255,255,255)"><span style=3D"color:rgb(153,0,255)"><b>"Commo=
n Lisp"</b></span></span> <b>{</b><br>&nbsp; <span style=3D"color:rgb(0,0,2=
55)"><b>class</b></span> <span style=3D"color:rgb(153,0,255)"><b>"|My Class=
|"</b></span> <b>{</b><br>&nbsp;&nbsp;&nbsp; <span style=3D"color:rgb(0,0,2=
55)"><b>public</b></span><b>:</b><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span s=
tyle=3D"color:rgb(0,0,255)"><b>int</b></span> <span style=3D"color:rgb(153,=
0,255)"><b>"myv@r"</b></span><b>;</b><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <sp=
an style=3D"color:rgb(0,0,255)"><b>void</b></span> <b>*</b><span style=3D"c=
olor:rgb(153,0,255)"><b>"didStuff?"</b></span><b>(</b><span style=3D"color:=
rgb(0,0,255)"><b>int</b></span><b>);</b><br>&nbsp; <b>};</b><br>&nbsp; <b><=
span style=3D"color:rgb(0,0,255)">void</span></b> <b><span style=3D"color:r=
gb(153,0,255)">"some-random-function"</span>();</b><br><b>};</b><br><br><b>=
<span style=3D"color:rgb(153,0,255)">"|My Class|"</span></b> <b>*</b>x <b>=
=3D</b> <span style=3D"color:rgb(0,0,255)"><b>new</b></span> <span style=3D=
"color:rgb(153,0,255)"><b>"|My Class|"</b></span><b>;</b><br><b><span style=
=3D"color:rgb(0,0,255)">void</span></b> <b>*</b>y <b>=3D</b> x<b>-&gt;</b><=
span style=3D"color:rgb(153,0,255)"><b>"didStuff?"</b></span><b>(</b><span =
style=3D"color:rgb(61,133,198)">42</span><b>);</b><br>cout <b>&lt;&lt;</b> =
x<b>-&gt;</b><span style=3D"color:rgb(153,0,255)"><b>"myv@r"</b></span> <b>=
&lt;&lt;</b> endl;<br><b><span style=3D"color:rgb(153,0,255)">"some-random-=
function"</span>();</b></span><br></div><br><br>What do you guys think? Any=
one has another idea?<br><br>After implementing this behaviour on my compil=
er, I intend to propose this extension to the standard.<br></div></blockquo=
te></div></div></blockquote></div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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_812_642478.1382048448292--

.


Author: David Krauss <potswa@gmail.com>
Date: Thu, 31 Oct 2013 17:09:26 +0800
Raw View
On 10/18/13 2:19 AM, paulo_torrens@ekolivre.com.br wrote:
> What do you guys think? Anyone has another idea?

Rather than allowing any arbitrary character sequence to become an
identifier, you might add a custom string prefix. Currently, characters
before the first quote of a string may have special meaning, such as
R"()" or L"". You could use I"" for a string literal preprocessing token
that should become an identifier token after preprocessing.

> After implementing this behaviour on my compiler, I intend to propose this
> extension to the standard.

Features under the umbrella of implementation-defined semantics aren't
usually standardized unless already implemented by essentially all
implementations, so there's no way you'll get ISO certification. Even
fixtures like __COUNTER__, #pragma once, and headers inside
subdirectories are in this purgatory.

Unfortunately, additional string prefixes aren't strictly compliant
because you also preempt a valid macro called I which expands to a string:

#define I "hello"

int main() {
std::cout << I", world\n";
}

The noncompliance is however probably acceptable. If you're feeling
really anal, you could have the preprocessor detect the token sequence
<extern "Objective-C"> and direct the lexer to only generate the string
prefix from that point onward. This requires simultaneous lexing and
preprocessing; I have written such a preprocessor but I'm not sure how
it would fit with Clang and GCC.

--

---
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/.

.