Topic: Call magic method


Author: tl <timlenertz@gmail.com>
Date: Thu, 14 Aug 2014 13:11:43 -0700 (PDT)
Raw View
------=_Part_776_209334077.1408047103610
Content-Type: text/plain; charset=UTF-8

Scripting languages (e.g. PHP) often have a "__call" magic method for
handling calls to undefined method names. For example in PHP it is useful
to implement a nice interface to a RPC system or a database abstraction
layer:

class RemoteObject {
  public function connect() {
    $this->_socket->connect();
  }
  public function __call($method, $args) {
    $this->_socket->request($method, json_encore($args));
    return $this->_socket->receiveResponse();
  }
}


$r = getRemoteObject();
$r->connect(); // calls the connect() method
echo $r->getMessage("test"); // calls __call("getMessage", array("test"))


Python also has a "__call__" magic method. Objective-C also has this with
the

- (retval_t)forward:(SEL)sel args:(arglist_t)args

message, and it is used in Cocoa (NSDistantObject)

Since a lot of C++ seems to designed so that a clean interface to classes
can be provided (e.g. operator overloading, initialisation lists, etc), I
was wondering if it would make sense to add a similar feature to C++. For
example like:

class remote_object : public socket {
  ...
public:
  std::string operator->(const char* msg, int arg) {
    std::cout << "called " << msg << " with " << arg << std::endl;
    return "";
  }

  // or for variable augment types
  template<typename... Args>
  std::string operator->(const char* msg, Args&&... args) {
    return dispatch_(msg, std::forward<Args>(args)...);
  }

  void connect();
}

int main() {
   remote_object& ro = ...;
   ro.connect();
   ro->getMessage("test"); // instead of something like
ro.send("getMessage", "test") or ro("getMessage", "test")
}

If using operator-> (or even operator.) causes too much ambiguity, maybe
there could be a new operator like --> or ..
Using a string for the message name is of course possible using
ro.operator->("message", "arg")



--

---
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_776_209334077.1408047103610
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Scripting languages (e.g. PHP) often have a "__call" magic=
 method for handling calls to undefined method names. For example in PHP it=
 is useful to implement a nice interface to a RPC system or a database abst=
raction layer:<div><font color=3D"#660066"><br></font></div><div><div class=
=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border: 1px=
 solid rgb(187, 187, 187); word-wrap: break-word;"><code class=3D"prettypri=
nt"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">class</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettif=
y">RemoteObject</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </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; </=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">public</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">function</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> connect</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">()</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </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; $this</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">-&gt;</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify">_socket</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">-&gt;</span><font color=3D"#000000"><span style=
=3D"color: #000;" class=3D"styled-by-prettify">connect</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">();</span></font><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>&nbsp; </span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">public</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">function</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> __call</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">$method</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 $args</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </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; $this</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">-&gt;</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">_socket</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">-&gt;</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify">request</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify">$method</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> json_encore</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">$args</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">));</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">return</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> $this</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">-&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">_s=
ocket</span><span style=3D"color: #660;" class=3D"styled-by-prettify">-&gt;=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">receiveRes=
ponse</span><span style=3D"color: #660;" class=3D"styled-by-prettify">();</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; <=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br><br><br>$r </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> getRemoteObject</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">();</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br>$r</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">-&gt;</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify">connect</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">(</span><font color=3D"#000000"><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: #800;" cla=
ss=3D"styled-by-prettify">// calls the connect() method</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span></font><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">echo $r</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">-&gt;</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">getMessage</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #08=
0;" class=3D"styled-by-prettify">"test"</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: #800;" class=3D"styled-b=
y-prettify">// calls __call("getMessage", array("test"))</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span></div></code>=
</div><br>Python also has a "__call__" magic method. Objective-C also has t=
his with the</div><div><pre class=3D"de1" style=3D"font-family: monospace, =
monospace; color: rgb(0, 0, 0); background-color: rgb(249, 249, 249); borde=
r-style: none; border-color: white; line-height: 1.2em; tab-size: 4; font-s=
ize: 14px; background-image: none; vertical-align: top;"><span class=3D"sy0=
" style=3D"color: rgb(0, 34, 0);">-</span> <span class=3D"br0" style=3D"col=
or: rgb(0, 34, 0);">(</span>retval_t<span class=3D"br0" style=3D"color: rgb=
(0, 34, 0);">)</span>forward<span class=3D"sy0" style=3D"color: rgb(0, 34, =
0);">:</span><span class=3D"br0" style=3D"color: rgb(0, 34, 0);">(</span><s=
pan class=3D"kw4" style=3D"color: rgb(166, 19, 144);">SEL</span><span class=
=3D"br0" style=3D"color: rgb(0, 34, 0);">)</span>sel args<span class=3D"sy0=
" style=3D"color: rgb(0, 34, 0);">:</span><span class=3D"br0" style=3D"colo=
r: rgb(0, 34, 0);">(</span>arglist_t<span class=3D"br0" style=3D"color: rgb=
(0, 34, 0);">)</span>args</pre></div><div>message, and it is used in Cocoa =
(NSDistantObject)</div><div><br></div><div>Since a lot of C++ seems to desi=
gned so that a clean interface to classes can be provided (e.g. operator ov=
erloading, initialisation lists, etc), I was wondering if it would make sen=
se to add a similar feature to C++. For example like:</div><div><br></div><=
div><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250=
); border: 1px solid rgb(187, 187, 187); word-wrap: break-word;"><code clas=
s=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;=
" class=3D"styled-by-prettify">class</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> remote_object </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: #008;" class=3D"style=
d-by-prettify">public</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> socket </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br>&nbsp; </span><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: #008;" class=3D"styled-by-prettify">public</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; std</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">string</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">operator</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">-&gt;(</span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">const</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">char</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">*</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 msg</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> arg</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"=
styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br>&nbsp; &nbsp; std</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">cout </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #080;" class=3D"styled-by-prettify">=
"called "</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> msg </span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><font color=
=3D"#666600"><span style=3D"color: #080;" class=3D"styled-by-prettify">" wi=
th "</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> arg </span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span></font>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><font col=
or=3D"#008800"><span style=3D"color: #000;" class=3D"styled-by-prettify">st=
d</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify">endl</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br></span></font><span style=3D=
"color: #000;" class=3D"styled-by-prettify">&nbsp; &nbsp; </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">return</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #=
080;" class=3D"styled-by-prettify">""</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br>&nbsp; </span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br><br>&nbsp; </span><span style=3D"color: #800;" class=3D"style=
d-by-prettify">// or for variable augment types</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"><br>&nbsp; </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">template</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #008;"=
 class=3D"styled-by-prettify">typename</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">...</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-b=
y-prettify">Args</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br>&nbsp; std</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">::</span><span style=3D"color: #008;" class=3D"styled-by-prettify">stri=
ng</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">operator</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">-&gt;(</span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">const</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">char</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">*</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> msg</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">=
Args</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;&=
amp;...</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> ar=
gs</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">return</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> dispatch_</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">msg</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> std</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify">forward</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">&lt;</span><span style=3D"color: #606;" class=3D"styled-by-prettify">Args=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;(</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">args</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">)...);</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br><br>&nbsp; </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">void</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> connect</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">()</span><font color=3D"#000000"><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">;</span></font><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"color=
: #000;" class=3D"styled-by-prettify"><br><br></span><span style=3D"color: =
#008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> main</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">()</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r>&nbsp; &nbsp;remote_object</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">&amp;</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> ro </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">...;</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp;</spa=
n><font color=3D"#666600"><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> &nbsp;ro</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">c=
onnect</span><span style=3D"color: #660;" class=3D"styled-by-prettify">();<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span>=
</font><span style=3D"color: #000;" class=3D"styled-by-prettify">&nbsp; &nb=
sp;ro</span><span style=3D"color: #660;" class=3D"styled-by-prettify">-&gt;=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">getMessage=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><s=
pan style=3D"color: #080;" class=3D"styled-by-prettify">"test"</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: #=
800;" class=3D"styled-by-prettify">// instead of something like ro.send("ge=
tMessage", "test") or ro("getMessage", "test")</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">}</span></div></code></div><br>If using opera=
tor-&gt; (or even operator.) causes too much ambiguity, maybe there could b=
e a new operator like --&gt; or ..</div><div>Using a string for the message=
 name is of course possible using ro.operator-&gt;("message", "arg")</div><=
div><br></div><div><br></div><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 />

------=_Part_776_209334077.1408047103610--

.


Author: Andrew Tomazos <andrewtomazos@gmail.com>
Date: Thu, 14 Aug 2014 22:26:42 +0200
Raw View
--047d7bd6c01604855605009cb9c1
Content-Type: text/plain; charset=UTF-8

Yeah I'm working on something like this, I'm calling __anyname__.

Current design looks like this:

template<char... name>
int __anyname__;

foo = 3; // same as __anyname__<'f','o'o'> = 3
bar = 4; // same as __anyname__<'b','a','r'> = 4

baz = foo + bar; // same as __anyname__<'b','a','z'> =
__anyname__<'f','o','o'> + __anyname__<'b','a','r'>

If name lookup fails on an identifier abcd, it is (logically) tried again
on the template id __anyname__<'a','b','c','d'>

It's based in part of the work of Sebastian Redl on operator.:
https://www.youtube.com/embed/Gy9ITl1AWRY and likewise the "magic" names as
you call them from scripting languages.  The one I know of is Perl AUTOLOAD
which is pretty much the same as the ones you mentioned.



On Thu, Aug 14, 2014 at 10:11 PM, tl <timlenertz@gmail.com> wrote:

> Scripting languages (e.g. PHP) often have a "__call" magic method for
> handling calls to undefined method names. For example in PHP it is useful
> to implement a nice interface to a RPC system or a database abstraction
> layer:
>
> class RemoteObject {
>   public function connect() {
>     $this->_socket->connect();
>   }
>   public function __call($method, $args) {
>     $this->_socket->request($method, json_encore($args));
>     return $this->_socket->receiveResponse();
>   }
> }
>
>
> $r = getRemoteObject();
> $r->connect(); // calls the connect() method
> echo $r->getMessage("test"); // calls __call("getMessage", array("test"))
>
>
> Python also has a "__call__" magic method. Objective-C also has this with
> the
>
> - (retval_t)forward:(SEL)sel args:(arglist_t)args
>
> message, and it is used in Cocoa (NSDistantObject)
>
> Since a lot of C++ seems to designed so that a clean interface to classes
> can be provided (e.g. operator overloading, initialisation lists, etc), I
> was wondering if it would make sense to add a similar feature to C++. For
> example like:
>
> class remote_object : public socket {
>   ...
> public:
>   std::string operator->(const char* msg, int arg) {
>     std::cout << "called " << msg << " with " << arg << std::endl;
>     return "";
>   }
>
>   // or for variable augment types
>   template<typename... Args>
>   std::string operator->(const char* msg, Args&&... args) {
>     return dispatch_(msg, std::forward<Args>(args)...);
>   }
>
>   void connect();
> }
>
> int main() {
>    remote_object& ro = ...;
>    ro.connect();
>    ro->getMessage("test"); // instead of something like
> ro.send("getMessage", "test") or ro("getMessage", "test")
> }
>
> If using operator-> (or even operator.) causes too much ambiguity, maybe
> there could be a new operator like --> or ..
> Using a string for the message name is of course possible using
> ro.operator->("message", "arg")
>
>
>
>  --
>
> ---
> 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/.

--047d7bd6c01604855605009cb9c1
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Yeah I&#39;m working on something like this, I&#39;m calli=
ng __anyname__.<div><br></div><div>Current design looks like this:</div><di=
v><br></div><div>template&lt;char... name&gt;</div><div>int __anyname__;</d=
iv>
<div><br></div><div>foo =3D 3; // same as __anyname__&lt;&#39;f&#39;,&#39;o=
&#39;o&#39;&gt; =3D 3</div><div>bar =3D 4; // same as __anyname__&lt;&#39;b=
&#39;,&#39;a&#39;,&#39;r&#39;&gt; =3D 4</div><div><br></div><div>baz =3D fo=
o + bar; // same as __anyname__&lt;&#39;b&#39;,&#39;a&#39;,&#39;z&#39;&gt; =
=3D __anyname__&lt;&#39;f&#39;,&#39;o&#39;,&#39;o&#39;&gt; + __anyname__&lt=
;&#39;b&#39;,&#39;a&#39;,&#39;r&#39;&gt;</div>
<div><br></div><div>If name lookup fails on an identifier abcd, it is (logi=
cally) tried again on the template id __anyname__&lt;&#39;a&#39;,&#39;b&#39=
;,&#39;c&#39;,&#39;d&#39;&gt;<br><div><div class=3D"gmail_extra"><br></div>
<div class=3D"gmail_extra">It&#39;s based in part of the work of Sebastian =
Redl on operator.:=C2=A0<a href=3D"https://www.youtube.com/embed/Gy9ITl1AWR=
Y">https://www.youtube.com/embed/Gy9ITl1AWRY</a> and likewise the &quot;mag=
ic&quot; names as you call them from scripting languages. =C2=A0The one I k=
now of is Perl AUTOLOAD which is pretty much the same as the ones you menti=
oned.</div>
<div class=3D"gmail_extra"><br></div><div class=3D"gmail_extra"><br><br><di=
v class=3D"gmail_quote">On Thu, Aug 14, 2014 at 10:11 PM, tl <span dir=3D"l=
tr">&lt;<a href=3D"mailto:timlenertz@gmail.com" target=3D"_blank">timlenert=
z@gmail.com</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;p=
adding-left:1ex"><div dir=3D"ltr">Scripting languages (e.g. PHP) often have=
 a &quot;__call&quot; magic method for handling calls to undefined method n=
ames. For example in PHP it is useful to implement a nice interface to a RP=
C system or a database abstraction layer:<div>

<font color=3D"#660066"><br></font></div><div><div style=3D"border:1px soli=
d rgb(187,187,187);word-wrap:break-word;background-color:rgb(250,250,250)">=
<code><div><span style=3D"color:rgb(0,0,136)">class</span><span style=3D"co=
lor:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,102)">RemoteObject</=
span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,=
102,0)">{</span><span style=3D"color:rgb(0,0,0)"><br>

=C2=A0 </span><span style=3D"color:rgb(0,0,136)">public</span><span style=
=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,0,136)">function</=
span><span style=3D"color:rgb(0,0,0)"> connect</span><span style=3D"color:r=
gb(102,102,0)">()</span><span style=3D"color:rgb(0,0,0)"> </span><span styl=
e=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0,0)"><br>

=C2=A0 =C2=A0 $this</span><span style=3D"color:rgb(102,102,0)">-&gt;</span>=
<span style=3D"color:rgb(0,0,0)">_socket</span><span style=3D"color:rgb(102=
,102,0)">-&gt;</span><font color=3D"#000000"><span style=3D"color:rgb(0,0,0=
)">connect</span><span style=3D"color:rgb(102,102,0)">();</span></font><spa=
n style=3D"color:rgb(0,0,0)"><br>

=C2=A0 </span><span style=3D"color:rgb(102,102,0)">}</span><span style=3D"c=
olor:rgb(0,0,0)"><br>=C2=A0 </span><span style=3D"color:rgb(0,0,136)">publi=
c</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0=
,0,136)">function</span><span style=3D"color:rgb(0,0,0)"> __call</span><spa=
n style=3D"color:rgb(102,102,0)">(</span><span style=3D"color:rgb(0,0,0)">$=
method</span><span style=3D"color:rgb(102,102,0)">,</span><span style=3D"co=
lor:rgb(0,0,0)"> $args</span><span style=3D"color:rgb(102,102,0)">)</span><=
span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,102,0)=
">{</span><span style=3D"color:rgb(0,0,0)"><br>

=C2=A0 =C2=A0 $this</span><span style=3D"color:rgb(102,102,0)">-&gt;</span>=
<span style=3D"color:rgb(0,0,0)">_socket</span><span style=3D"color:rgb(102=
,102,0)">-&gt;</span><span style=3D"color:rgb(0,0,0)">request</span><span s=
tyle=3D"color:rgb(102,102,0)">(</span><span style=3D"color:rgb(0,0,0)">$met=
hod</span><span style=3D"color:rgb(102,102,0)">,</span><span style=3D"color=
:rgb(0,0,0)"> json_encore</span><span style=3D"color:rgb(102,102,0)">(</spa=
n><span style=3D"color:rgb(0,0,0)">$args</span><span style=3D"color:rgb(102=
,102,0)">));</span><span style=3D"color:rgb(0,0,0)"><br>

=C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,0,136)">return</span><span =
style=3D"color:rgb(0,0,0)"> $this</span><span style=3D"color:rgb(102,102,0)=
">-&gt;</span><span style=3D"color:rgb(0,0,0)">_socket</span><span style=3D=
"color:rgb(102,102,0)">-&gt;</span><span style=3D"color:rgb(0,0,0)">receive=
Response</span><span style=3D"color:rgb(102,102,0)">();</span><span style=
=3D"color:rgb(0,0,0)"><br>

=C2=A0 </span><span style=3D"color:rgb(102,102,0)">}</span><span style=3D"c=
olor:rgb(0,0,0)"><br></span><span style=3D"color:rgb(102,102,0)">}</span><s=
pan style=3D"color:rgb(0,0,0)"><br><br><br>$r </span><span style=3D"color:r=
gb(102,102,0)">=3D</span><span style=3D"color:rgb(0,0,0)"> getRemoteObject<=
/span><span style=3D"color:rgb(102,102,0)">();</span><span style=3D"color:r=
gb(0,0,0)"><br>

$r</span><span style=3D"color:rgb(102,102,0)">-&gt;</span><span style=3D"co=
lor:rgb(0,0,0)">connect</span><span style=3D"color:rgb(102,102,0)">(</span>=
<font color=3D"#000000"><span style=3D"color:rgb(102,102,0)">);</span><span=
 style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(136,0,0)">// c=
alls the connect() method</span><span style=3D"color:rgb(0,0,0)"><br>

</span></font><span style=3D"color:rgb(0,0,0)">echo $r</span><span style=3D=
"color:rgb(102,102,0)">-&gt;</span><span style=3D"color:rgb(0,0,0)">getMess=
age</span><span style=3D"color:rgb(102,102,0)">(</span><span style=3D"color=
:rgb(0,136,0)">&quot;test&quot;</span><span style=3D"color:rgb(102,102,0)">=
);</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(=
136,0,0)">// calls __call(&quot;getMessage&quot;, array(&quot;test&quot;))<=
/span><span style=3D"color:rgb(0,0,0)"><br>

<br></span></div></code></div><br>Python also has a &quot;__call__&quot; ma=
gic method. Objective-C also has this with the</div><div><pre style=3D"font=
-family:monospace,monospace;color:rgb(0,0,0);border-style:none;border-color=
:white;line-height:1.2em;font-size:14px;vertical-align:top;background-image=
:none;background-color:rgb(249,249,249)">
<span style=3D"color:rgb(0,34,0)">-</span> <span style=3D"color:rgb(0,34,0)=
">(</span>retval_t<span style=3D"color:rgb(0,34,0)">)</span>forward<span st=
yle=3D"color:rgb(0,34,0)">:</span><span style=3D"color:rgb(0,34,0)">(</span=
><span style=3D"color:rgb(166,19,144)">SEL</span><span style=3D"color:rgb(0=
,34,0)">)</span>sel args<span style=3D"color:rgb(0,34,0)">:</span><span sty=
le=3D"color:rgb(0,34,0)">(</span>arglist_t<span style=3D"color:rgb(0,34,0)"=
>)</span>args</pre>

</div><div>message, and it is used in Cocoa (NSDistantObject)</div><div><br=
></div><div>Since a lot of C++ seems to designed so that a clean interface =
to classes can be provided (e.g. operator overloading, initialisation lists=
, etc), I was wondering if it would make sense to add a similar feature to =
C++. For example like:</div>

<div><br></div><div><div style=3D"border:1px solid rgb(187,187,187);word-wr=
ap:break-word;background-color:rgb(250,250,250)"><code><div><span style=3D"=
color:rgb(0,0,136)">class</span><span style=3D"color:rgb(0,0,0)"> remote_ob=
ject </span><span style=3D"color:rgb(102,102,0)">:</span><span style=3D"col=
or:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,0,136)">public</span><spa=
n style=3D"color:rgb(0,0,0)"> socket </span><span style=3D"color:rgb(102,10=
2,0)">{</span><span style=3D"color:rgb(0,0,0)"><br>

=C2=A0 </span><span style=3D"color:rgb(102,102,0)">...</span><span style=3D=
"color:rgb(0,0,0)"><br></span><span style=3D"color:rgb(0,0,136)">public</sp=
an><span style=3D"color:rgb(102,102,0)">:</span><span style=3D"color:rgb(0,=
0,0)"><br>
=C2=A0 std</span><span style=3D"color:rgb(102,102,0)">::</span><span style=
=3D"color:rgb(0,0,136)">string</span><span style=3D"color:rgb(0,0,0)"> </sp=
an><span style=3D"color:rgb(0,0,136)">operator</span><span style=3D"color:r=
gb(102,102,0)">-&gt;(</span><span style=3D"color:rgb(0,0,136)">const</span>=
<span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,0,136)"=
>char</span><span style=3D"color:rgb(102,102,0)">*</span><span style=3D"col=
or:rgb(0,0,0)"> msg</span><span style=3D"color:rgb(102,102,0)">,</span><spa=
n style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,0,136)">int=
</span><span style=3D"color:rgb(0,0,0)"> arg</span><span style=3D"color:rgb=
(102,102,0)">)</span><span style=3D"color:rgb(0,0,0)"> </span><span style=
=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0,0)"><br>

=C2=A0 =C2=A0 std</span><span style=3D"color:rgb(102,102,0)">::</span><span=
 style=3D"color:rgb(0,0,0)">cout </span><span style=3D"color:rgb(102,102,0)=
">&lt;&lt;</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"co=
lor:rgb(0,136,0)">&quot;called &quot;</span><span style=3D"color:rgb(0,0,0)=
"> </span><span style=3D"color:rgb(102,102,0)">&lt;&lt;</span><span style=
=3D"color:rgb(0,0,0)"> msg </span><span style=3D"color:rgb(102,102,0)">&lt;=
&lt;</span><span style=3D"color:rgb(0,0,0)"> </span><font color=3D"#666600"=
><span style=3D"color:rgb(0,136,0)">&quot; with &quot;</span><span style=3D=
"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,102,0)">&lt;&lt;</s=
pan><span style=3D"color:rgb(0,0,0)"> arg </span><span style=3D"color:rgb(1=
02,102,0)">&lt;&lt;</span></font><span style=3D"color:rgb(0,0,0)"> </span><=
font color=3D"#008800"><span style=3D"color:rgb(0,0,0)">std</span><span sty=
le=3D"color:rgb(102,102,0)">::</span><span style=3D"color:rgb(0,0,0)">endl<=
/span><span style=3D"color:rgb(102,102,0)">;</span><span style=3D"color:rgb=
(0,0,0)"><br>

</span></font><span style=3D"color:rgb(0,0,0)">=C2=A0 =C2=A0 </span><span s=
tyle=3D"color:rgb(0,0,136)">return</span><span style=3D"color:rgb(0,0,0)"> =
</span><span style=3D"color:rgb(0,136,0)">&quot;&quot;</span><span style=3D=
"color:rgb(102,102,0)">;</span><span style=3D"color:rgb(0,0,0)"><br>

=C2=A0 </span><span style=3D"color:rgb(102,102,0)">}</span><span style=3D"c=
olor:rgb(0,0,0)"><br><br>=C2=A0 </span><span style=3D"color:rgb(136,0,0)">/=
/ or for variable augment types</span><span style=3D"color:rgb(0,0,0)"><br>=
=C2=A0 </span><span style=3D"color:rgb(0,0,136)">template</span><span style=
=3D"color:rgb(102,102,0)">&lt;</span><span style=3D"color:rgb(0,0,136)">typ=
ename</span><span style=3D"color:rgb(102,102,0)">...</span><span style=3D"c=
olor:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,102)">Args</span><s=
pan style=3D"color:rgb(102,102,0)">&gt;</span><span style=3D"color:rgb(0,0,=
0)"><br>

=C2=A0 std</span><span style=3D"color:rgb(102,102,0)">::</span><span style=
=3D"color:rgb(0,0,136)">string</span><span style=3D"color:rgb(0,0,0)"> </sp=
an><span style=3D"color:rgb(0,0,136)">operator</span><span style=3D"color:r=
gb(102,102,0)">-&gt;(</span><span style=3D"color:rgb(0,0,136)">const</span>=
<span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,0,136)"=
>char</span><span style=3D"color:rgb(102,102,0)">*</span><span style=3D"col=
or:rgb(0,0,0)"> msg</span><span style=3D"color:rgb(102,102,0)">,</span><spa=
n style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,102)">A=
rgs</span><span style=3D"color:rgb(102,102,0)">&amp;&amp;...</span><span st=
yle=3D"color:rgb(0,0,0)"> args</span><span style=3D"color:rgb(102,102,0)">)=
</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(10=
2,102,0)">{</span><span style=3D"color:rgb(0,0,0)"><br>

=C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,0,136)">return</span><span =
style=3D"color:rgb(0,0,0)"> dispatch_</span><span style=3D"color:rgb(102,10=
2,0)">(</span><span style=3D"color:rgb(0,0,0)">msg</span><span style=3D"col=
or:rgb(102,102,0)">,</span><span style=3D"color:rgb(0,0,0)"> std</span><spa=
n style=3D"color:rgb(102,102,0)">::</span><span style=3D"color:rgb(0,0,0)">=
forward</span><span style=3D"color:rgb(102,102,0)">&lt;</span><span style=
=3D"color:rgb(102,0,102)">Args</span><span style=3D"color:rgb(102,102,0)">&=
gt;(</span><span style=3D"color:rgb(0,0,0)">args</span><span style=3D"color=
:rgb(102,102,0)">)...);</span><span style=3D"color:rgb(0,0,0)"><br>

=C2=A0 </span><span style=3D"color:rgb(102,102,0)">}</span><span style=3D"c=
olor:rgb(0,0,0)"><br><br>=C2=A0 </span><span style=3D"color:rgb(0,0,136)">v=
oid</span><span style=3D"color:rgb(0,0,0)"> connect</span><span style=3D"co=
lor:rgb(102,102,0)">()</span><font color=3D"#000000"><span style=3D"color:r=
gb(102,102,0)">;</span></font><span style=3D"color:rgb(0,0,0)"><br>

</span><span style=3D"color:rgb(102,102,0)">}</span><span style=3D"color:rg=
b(0,0,0)"><br><br></span><span style=3D"color:rgb(0,0,136)">int</span><span=
 style=3D"color:rgb(0,0,0)"> main</span><span style=3D"color:rgb(102,102,0)=
">()</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rg=
b(102,102,0)">{</span><span style=3D"color:rgb(0,0,0)"><br>

=C2=A0 =C2=A0remote_object</span><span style=3D"color:rgb(102,102,0)">&amp;=
</span><span style=3D"color:rgb(0,0,0)"> ro </span><span style=3D"color:rgb=
(102,102,0)">=3D</span><span style=3D"color:rgb(0,0,0)"> </span><span style=
=3D"color:rgb(102,102,0)">...;</span><span style=3D"color:rgb(0,0,0)"><br>

=C2=A0</span><font color=3D"#666600"><span style=3D"color:rgb(0,0,0)"> =C2=
=A0ro</span><span style=3D"color:rgb(102,102,0)">.</span><span style=3D"col=
or:rgb(0,0,0)">connect</span><span style=3D"color:rgb(102,102,0)">();</span=
><span style=3D"color:rgb(0,0,0)"><br>
</span></font><span style=3D"color:rgb(0,0,0)">=C2=A0 =C2=A0ro</span><span =
style=3D"color:rgb(102,102,0)">-&gt;</span><span style=3D"color:rgb(0,0,0)"=
>getMessage</span><span style=3D"color:rgb(102,102,0)">(</span><span style=
=3D"color:rgb(0,136,0)">&quot;test&quot;</span><span style=3D"color:rgb(102=
,102,0)">);</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"c=
olor:rgb(136,0,0)">// instead of something like ro.send(&quot;getMessage&qu=
ot;, &quot;test&quot;) or ro(&quot;getMessage&quot;, &quot;test&quot;)</spa=
n><span style=3D"color:rgb(0,0,0)"><br>

</span><span style=3D"color:rgb(102,102,0)">}</span></div></code></div><br>=
If using operator-&gt; (or even operator.) causes too much ambiguity, maybe=
 there could be a new operator like --&gt; or ..</div><div>Using a string f=
or the message name is of course possible using ro.operator-&gt;(&quot;mess=
age&quot;, &quot;arg&quot;)</div>

<span><font color=3D"#888888"><div><br></div><div><br></div><div><br></div>=
</font></span></div><span><font color=3D"#888888">

<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>
</font></span></blockquote></div><br></div></div></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 />

--047d7bd6c01604855605009cb9c1--

.


Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Thu, 14 Aug 2014 23:31:00 +0300
Raw View
On 14 August 2014 23:26, Andrew Tomazos <andrewtomazos@gmail.com> wrote:
> Yeah I'm working on something like this, I'm calling __anyname__.
>
> Current design looks like this:
>
> template<char... name>
> int __anyname__;
>
> foo = 3; // same as __anyname__<'f','o'o'> = 3
> bar = 4; // same as __anyname__<'b','a','r'> = 4
>
> baz = foo + bar; // same as __anyname__<'b','a','z'> =
> __anyname__<'f','o','o'> + __anyname__<'b','a','r'>
>
> If name lookup fails on an identifier abcd, it is (logically) tried again on
> the template id __anyname__<'a','b','c','d'>

Do be careful with existing code that might try lookup tricks with SFINAE.

--

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

.


Author: Andrew Tomazos <andrewtomazos@gmail.com>
Date: Thu, 14 Aug 2014 22:59:47 +0200
Raw View
--90e6ba1efb7455228e05009d2f5a
Content-Type: text/plain; charset=UTF-8

On Thu, Aug 14, 2014 at 10:31 PM, Ville Voutilainen <
ville.voutilainen@gmail.com> wrote:

> On 14 August 2014 23:26, Andrew Tomazos <andrewtomazos@gmail.com> wrote:
> > Yeah I'm working on something like this, I'm calling __anyname__.
> >
> > Current design looks like this:
> >
> > template<char... name>
> > int __anyname__;
> >
> > foo = 3; // same as __anyname__<'f','o'o'> = 3
> > bar = 4; // same as __anyname__<'b','a','r'> = 4
> >
> > baz = foo + bar; // same as __anyname__<'b','a','z'> =
> > __anyname__<'f','o','o'> + __anyname__<'b','a','r'>
> >
> > If name lookup fails on an identifier abcd, it is (logically) tried
> again on
> > the template id __anyname__<'a','b','c','d'>
>
> Do be careful with existing code that might try lookup tricks with SFINAE.
>

Can you give me an example of what you mean?

--

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

--90e6ba1efb7455228e05009d2f5a
Content-Type: text/html; charset=UTF-8

<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Aug 14, 2014 at 10:31 PM, Ville Voutilainen <span dir="ltr">&lt;<a href="mailto:ville.voutilainen@gmail.com" target="_blank">ville.voutilainen@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On 14 August 2014 23:26, Andrew Tomazos &lt;<a href="mailto:andrewtomazos@gmail.com">andrewtomazos@gmail.com</a>&gt; wrote:<br>

&gt; Yeah I&#39;m working on something like this, I&#39;m calling __anyname__.<br>
&gt;<br>
&gt; Current design looks like this:<br>
&gt;<br>
&gt; template&lt;char... name&gt;<br>
&gt; int __anyname__;<br>
&gt;<br>
&gt; foo = 3; // same as __anyname__&lt;&#39;f&#39;,&#39;o&#39;o&#39;&gt; = 3<br>
&gt; bar = 4; // same as __anyname__&lt;&#39;b&#39;,&#39;a&#39;,&#39;r&#39;&gt; = 4<br>
&gt;<br>
&gt; baz = foo + bar; // same as __anyname__&lt;&#39;b&#39;,&#39;a&#39;,&#39;z&#39;&gt; =<br>
&gt; __anyname__&lt;&#39;f&#39;,&#39;o&#39;,&#39;o&#39;&gt; + __anyname__&lt;&#39;b&#39;,&#39;a&#39;,&#39;r&#39;&gt;<br>
&gt;<br>
&gt; If name lookup fails on an identifier abcd, it is (logically) tried again on<br>
&gt; the template id __anyname__&lt;&#39;a&#39;,&#39;b&#39;,&#39;c&#39;,&#39;d&#39;&gt;<br>
<br>
</div>Do be careful with existing code that might try lookup tricks with SFINAE.<br>
<div class="HOEnZb"><div class="h5"></div></div></blockquote></div><br></div><div class="gmail_extra">Can you give me an example of what you mean?</div><div class="gmail_extra"><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 email to <a href="mailto:std-proposals+unsubscribe@isocpp.org">std-proposals+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href="mailto:std-proposals@isocpp.org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href="http://groups.google.com/a/isocpp.org/group/std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/</a>.<br />

--90e6ba1efb7455228e05009d2f5a--

.


Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Fri, 15 Aug 2014 00:26:22 +0300
Raw View
On 14 August 2014 23:59, Andrew Tomazos <andrewtomazos@gmail.com> wrote:
>> Do be careful with existing code that might try lookup tricks with SFINAE.
> Can you give me an example of what you mean?


I'm not sure whether you're aiming to have this "anyname" for just
non-members or
for members as well. At least for members, I can detect their presence
with a custom
trait that SFINAEs into a false value if a sought-for member is not
found. That is
a lookup failure, and if you make the mistake of making that lookup
succeed, such
traits will break. I haven't tried similar techniques with
non-members, so I'm not sure
whether it applies to them; at any rate, be careful with the
compatibility with existing
code and traits that rely on lookup failure.

--

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

.


Author: David Krauss <potswa@gmail.com>
Date: Tue, 19 Aug 2014 13:19:11 +0800
Raw View
--Apple-Mail=_0F43A3FC-F677-456C-AAC9-C3D8837FC623
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-1


On 2014-08-15, at 4:26 AM, Andrew Tomazos <andrewtomazos@gmail.com> wrote:

> Yeah I'm working on something like this, I'm calling __anyname__.
>=20
> Current design looks like this:
>=20
> template<char... name>
> int __anyname__;

This looks similar to string literal operator templates, which IIRC have al=
ready been given the go-ahead by EWG. The only differences are the quotatio=
n marks, which I think add an essential level of safety to such a feature, =
and the identifier suffix, which allows two such templates to coexist. (Oth=
erwise, it effectively degenerates to JavaScript-like scoping rules where a=
ny undefined identifier becomes a global variable upon use.)

It might be nice to have nonstatic member string literal operator templates=
.. I've seen crazy workarounds where folks want to slice 3-vectors, and defi=
ne 3+3^2+3^3 members covering all solutions of the regex [xyz][xyz]?[xyz]?.=
 Database tables are another likely application.

The goal can be achieved using a non-member literal operator template retur=
ning a tag type and a subscript operator. But that loses the advantage of c=
ontaining the template in class scope, and could perhaps run into efficienc=
y snags if the tag needs to contain runtime data.

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

--Apple-Mail=_0F43A3FC-F677-456C-AAC9-C3D8837FC623
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=ISO-8859-1

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 2014&=
ndash;08&ndash;15, at 4:26 AM, Andrew Tomazos &lt;<a href=3D"mailto:andrewt=
omazos@gmail.com">andrewtomazos@gmail.com</a>&gt; wrote:</div><br class=3D"=
Apple-interchange-newline"><blockquote type=3D"cite"><div dir=3D"ltr">Yeah =
I'm working on something like this, I'm calling __anyname__.<div><br></div>=
<div>Current design looks like this:</div><div><br></div><div>template&lt;c=
har... name&gt;</div><div>int __anyname__;</div></div></blockquote><div><br=
></div><div>This looks similar to string literal operator templates, which =
IIRC have already been given the go-ahead by EWG. The only differences are =
the quotation marks, which I think add an essential level of safety to such=
 a feature, and the identifier suffix, which allows two such templates to c=
oexist. (Otherwise, it effectively degenerates to JavaScript-like scoping r=
ules where any undefined identifier becomes a global variable upon use.)</d=
iv><div><br></div><div>It might be nice to have nonstatic member string lit=
eral operator templates. I&rsquo;ve seen crazy workarounds where folks want=
 to slice 3-vectors, and define 3+3^2+3^3 members covering all solutions of=
 the regex <font face=3D"Courier">[xyz][xyz]?[xyz]?</font>. Database tables=
 are another likely application.</div><div><br></div><div>The goal can be a=
chieved using a non-member literal operator template returning a tag type a=
nd a subscript operator. But that loses the advantage of containing the tem=
plate in class scope, and could perhaps run into efficiency snags if the ta=
g needs to contain runtime data.</div></div><div><br></div></body></html>

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

--Apple-Mail=_0F43A3FC-F677-456C-AAC9-C3D8837FC623--

.


Author: Andrew Tomazos <andrewtomazos@gmail.com>
Date: Tue, 19 Aug 2014 07:49:30 +0200
Raw View
--089e01183b701dc2d00500f50dce
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Tue, Aug 19, 2014 at 7:19 AM, David Krauss <potswa@gmail.com> wrote:

>
> On 2014=E2=80=9308=E2=80=9315, at 4:26 AM, Andrew Tomazos <andrewtomazos@=
gmail.com> wrote:
>
> Yeah I'm working on something like this, I'm calling __anyname__.
>
> Current design looks like this:
>
> template<char... name>
> int __anyname__;
>
>
> This looks similar to string literal operator templates, which IIRC have
> already been given the go-ahead by EWG.
>

It's similar in the sense that it is passing text as a char pack.  The text
for a string literal operator template comes from a string literal token.
 The text in anyname comes from an identifier token.

The char pack version of string literals was not approved by ewg.  This is
issue 66: http://wg21.cmeerw.net/ewg/issue66

I just used char packs in the draft anyname design as a placeholder for
"whatever we do with compile-time strings".  Separately, we are looking at
what to actually do in the standard library with compile-time strings.  I
have N4121 in the works, but am considering withdrawing it as I would
rather have a literal class type with no template parameters, that can be
passed as a template parameter itself, this will require much more work
though, so I'm going to push for accepting some substitutes while we wait
for such a version to be possible.

The only differences are the quotation marks, which I think add an
> essential level of safety to such a feature, and the identifier suffix,
> which allows two such templates to coexist. (Otherwise, it effectively
> degenerates to JavaScript-like scoping rules where any undefined identifi=
er
> becomes a global variable upon use.)
>

Quotation marks don't add any extra safety.  You can just as easily make a
typo inside quotation marks as outside.  anyname isn't only for use at
global namespace scope, it's a general mechanism that works in any scope
and for any kind of template entity.

It might be nice to have nonstatic member string literal operator
> templates. I=E2=80=99ve seen crazy workarounds where folks want to slice =
3-vectors,
> and define 3+3^2+3^3 members covering all solutions of the regex
> [xyz][xyz]?[xyz]?. Database tables are another likely application.
>
> The goal can be achieved using a non-member literal operator template
> returning a tag type and a subscript operator. But that loses the advanta=
ge
> of containing the template in class scope, and could perhaps run into
> efficiency snags if the tag needs to contain runtime data.
>
>  --
>
> ---
> 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/.
>

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

--089e01183b701dc2d00500f50dce
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On T=
ue, Aug 19, 2014 at 7:19 AM, David Krauss <span dir=3D"ltr">&lt;<a href=3D"=
mailto:potswa@gmail.com" target=3D"_blank">potswa@gmail.com</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;p=
adding-left:1ex"><div style=3D"word-wrap:break-word"><br><div><div class=3D=
""><div>
On 2014=E2=80=9308=E2=80=9315, at 4:26 AM, Andrew Tomazos &lt;<a href=3D"ma=
ilto:andrewtomazos@gmail.com" target=3D"_blank">andrewtomazos@gmail.com</a>=
&gt; wrote:</div><br><blockquote type=3D"cite"><div dir=3D"ltr">Yeah I&#39;=
m working on something like this, I&#39;m calling __anyname__.<div>
<br></div><div>Current design looks like this:</div><div><br></div><div>tem=
plate&lt;char... name&gt;</div><div>int __anyname__;</div></div></blockquot=
e><div><br></div></div><div>This looks similar to string literal operator t=
emplates, which IIRC have already been given the go-ahead by EWG.</div>
</div></div></blockquote><div><br></div><div>It&#39;s similar in the sense =
that it is passing text as a char pack. =C2=A0The text for a string literal=
 operator template comes from a string literal token. =C2=A0The text in any=
name comes from an identifier token.</div>
<div>=C2=A0</div><div>The char pack version of string literals was not appr=
oved by ewg. =C2=A0This is issue 66:=C2=A0<a href=3D"http://wg21.cmeerw.net=
/ewg/issue66">http://wg21.cmeerw.net/ewg/issue66</a></div><div><br></div><d=
iv>I just used char packs in the draft anyname design as a placeholder for =
&quot;whatever we do with compile-time strings&quot;. =C2=A0Separately, we =
are looking at what to actually do in the standard library with compile-tim=
e strings. =C2=A0I have N4121 in the works, but am considering withdrawing =
it as I would rather have a literal class type with no template parameters,=
 that can be passed as a template parameter itself, this will require much =
more work though, so I&#39;m going to push for accepting some substitutes w=
hile we wait for such a version to be possible.</div>
<div><br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0p=
x 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-lef=
t-style:solid;padding-left:1ex"><div style=3D"word-wrap:break-word"><div><d=
iv>
The only differences are the quotation marks, which I think add an essentia=
l level of safety to such a feature, and the identifier suffix, which allow=
s two such templates to coexist. (Otherwise, it effectively degenerates to =
JavaScript-like scoping rules where any undefined identifier becomes a glob=
al variable upon use.)</div>
</div></div></blockquote><div><br></div><div>Quotation marks don&#39;t add =
any extra safety. =C2=A0You can just as easily make a typo inside quotation=
 marks as outside. =C2=A0anyname isn&#39;t only for use at global namespace=
 scope, it&#39;s a general mechanism that works in any scope and for any ki=
nd of template entity.</div>
<div><br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0p=
x 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-lef=
t-style:solid;padding-left:1ex"><div style=3D"word-wrap:break-word"><div><d=
iv>
</div><div>It might be nice to have nonstatic member string literal operato=
r templates. I=E2=80=99ve seen crazy workarounds where folks want to slice =
3-vectors, and define 3+3^2+3^3 members covering all solutions of the regex=
 <font face=3D"Courier">[xyz][xyz]?[xyz]?</font>. Database tables are anoth=
er likely application.</div>
<div><br></div><div>The goal can be achieved using a non-member literal ope=
rator template returning a tag type and a subscript operator. But that lose=
s the advantage of containing the template in class scope, and could perhap=
s run into efficiency snags if the tag needs to contain runtime data.</div>
</div><div><br></div></div><div class=3D""><div class=3D"h5">

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

--089e01183b701dc2d00500f50dce--

.


Author: David Krauss <potswa@gmail.com>
Date: Tue, 19 Aug 2014 13:59:06 +0800
Raw View
--Apple-Mail=_BC373F08-59D0-4208-B209-FB8B4219F16F
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-1


On 2014-08-19, at 1:49 PM, Andrew Tomazos <andrewtomazos@gmail.com> wrote:

> On Tue, Aug 19, 2014 at 7:19 AM, David Krauss <potswa@gmail.com> wrote:
>=20
> The only differences are the quotation marks, which I think add an essent=
ial level of safety to such a feature, and the identifier suffix, which all=
ows two such templates to coexist. (Otherwise, it effectively degenerates t=
o JavaScript-like scoping rules where any undefined identifier becomes a gl=
obal variable upon use.)
>=20
> Quotation marks don't add any extra safety.  You can just as easily make =
a typo inside quotation marks as outside.  anyname isn't only for use at gl=
obal namespace scope, it's a general mechanism that works in any scope and =
for any kind of template entity.

The safety is to protect folks who don't intend to use the anyname feature =
at all. This is what happens in JavaScript: misspell any unqualified identi=
fier lvalue and it helpfully generates a global variable. (The misfeature i=
s disabled in "strict mode" IIRC.)

Templates currently may only be defined at namespace or class scope, and th=
ere are no nonstatic member variable templates. I guess having all misspell=
ings map to unintended types is slightly less dangerous than global variabl=
es, but it would still be banned by any reasonable style policy, and disuse=
d by every library that intends compatibility with other libraries.

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

--Apple-Mail=_BC373F08-59D0-4208-B209-FB8B4219F16F
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=ISO-8859-1

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 2014&=
ndash;08&ndash;19, at 1:49 PM, Andrew Tomazos &lt;<a href=3D"mailto:andrewt=
omazos@gmail.com">andrewtomazos@gmail.com</a>&gt; wrote:</div><br class=3D"=
Apple-interchange-newline"><blockquote type=3D"cite"><div dir=3D"ltr"><div =
class=3D"gmail_extra"><div class=3D"gmail_quote">On Tue, Aug 19, 2014 at 7:=
19 AM, David Krauss <span dir=3D"ltr">&lt;<a href=3D"mailto:potswa@gmail.co=
m" target=3D"_blank">potswa@gmail.com</a>&gt;</span> wrote:<br>
<div><br></div><blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0=
px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); bo=
rder-left-style: solid; padding-left: 1ex; position: static; z-index: auto;=
"><div style=3D"word-wrap:break-word"><div>
The only differences are the quotation marks, which I think add an essentia=
l level of safety to such a feature, and the identifier suffix, which allow=
s two such templates to coexist. (Otherwise, it effectively degenerates to =
JavaScript-like scoping rules where any undefined identifier becomes a glob=
al variable upon use.)</div>
</div></blockquote><div><br></div><div>Quotation marks don't add any extra =
safety. &nbsp;You can just as easily make a typo inside quotation marks as =
outside. &nbsp;anyname isn't only for use at global namespace scope, it's a=
 general mechanism that works in any scope and for any kind of template ent=
ity.</div></div></div></div></blockquote><div><br></div><div>The safety is =
to protect folks who don&rsquo;t intend to use the anyname feature at all. =
This is what happens in JavaScript: misspell any unqualified identifier lva=
lue and it helpfully generates a global variable. (The misfeature is disabl=
ed in &ldquo;strict mode&rdquo; IIRC.)</div><div><br></div><div>Templates c=
urrently may only be defined at namespace or class scope, and there are no =
nonstatic member variable templates. I guess having all misspellings map to=
 unintended types is slightly less dangerous than global variables, but it =
would still be banned by any reasonable style policy, and disused by every =
library that intends compatibility with other libraries.</div></div><div><b=
r></div></body></html>

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

--Apple-Mail=_BC373F08-59D0-4208-B209-FB8B4219F16F--

.


Author: Andrew Tomazos <andrewtomazos@gmail.com>
Date: Tue, 19 Aug 2014 08:20:15 +0200
Raw View
--001a1135fd5c16bd7e0500f57b50
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Tue, Aug 19, 2014 at 7:59 AM, David Krauss <potswa@gmail.com> wrote:

>
> On 2014=E2=80=9308=E2=80=9319, at 1:49 PM, Andrew Tomazos <andrewtomazos@=
gmail.com> wrote:
>
> On Tue, Aug 19, 2014 at 7:19 AM, David Krauss <potswa@gmail.com> wrote:
>
> The only differences are the quotation marks, which I think add an
>> essential level of safety to such a feature, and the identifier suffix,
>> which allows two such templates to coexist. (Otherwise, it effectively
>> degenerates to JavaScript-like scoping rules where any undefined identif=
ier
>> becomes a global variable upon use.)
>>
>
> Quotation marks don't add any extra safety.  You can just as easily make =
a
> typo inside quotation marks as outside.  anyname isn't only for use at
> global namespace scope, it's a general mechanism that works in any scope
> and for any kind of template entity.
>
>
> The safety is to protect folks who don=E2=80=99t intend to use the anynam=
e feature
> at all. This is what happens in JavaScript: misspell any unqualified
> identifier lvalue and it helpfully generates a global variable. (The
> misfeature is disabled in =E2=80=9Cstrict mode=E2=80=9D IIRC.)
>
> Templates currently may only be defined at namespace or class scope, and
> there are no nonstatic member variable templates. I guess having all
> misspellings map to unintended types is slightly less dangerous than glob=
al
> variables, but it would still be banned by any reasonable style policy, a=
nd
> disused by every library that intends compatibility with other libraries.
>

Unqualified name lookup will only find an anyname template if one is in one
of the scopes searched.  So if you don't want that, don't put one there.
 Yes, library authors need to coordinate with program authors on what
language features they use and how.

Also, as a template you can place constraints on what the name can be at
compile-time as a predicate/concept on the name or other factors.  You can
also store the text and check it at run-time.

You did watch Redl's presentation right?
https://www.youtube.com/embed/Gy9ITl1AWRY

Yes, the anyname design needs some work on non-static member variables.
 There is ongoing work on operator. (current work, not Redls) that I
anticipate to complement anyname.  I'm still working out some of the
details.

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

--001a1135fd5c16bd7e0500f57b50
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On T=
ue, Aug 19, 2014 at 7:59 AM, David Krauss <span dir=3D"ltr">&lt;<a href=3D"=
mailto:potswa@gmail.com" target=3D"_blank">potswa@gmail.com</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;p=
adding-left:1ex"><div style=3D"word-wrap:break-word"><br><div><div class=3D=
""><div>
On 2014=E2=80=9308=E2=80=9319, at 1:49 PM, Andrew Tomazos &lt;<a href=3D"ma=
ilto:andrewtomazos@gmail.com" target=3D"_blank">andrewtomazos@gmail.com</a>=
&gt; wrote:</div><br></div><blockquote type=3D"cite"><div dir=3D"ltr"><div =
class=3D"gmail_extra">
<div class=3D"gmail_quote"><div class=3D"">On Tue, Aug 19, 2014 at 7:19 AM,=
 David Krauss <span dir=3D"ltr">&lt;<a href=3D"mailto:potswa@gmail.com" tar=
get=3D"_blank">potswa@gmail.com</a>&gt;</span> wrote:<br>
<div><br></div></div><div class=3D""><blockquote class=3D"gmail_quote" styl=
e=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(2=
04,204,204);border-left-style:solid;padding-left:1ex"><div style=3D"word-wr=
ap:break-word">
<div>
The only differences are the quotation marks, which I think add an essentia=
l level of safety to such a feature, and the identifier suffix, which allow=
s two such templates to coexist. (Otherwise, it effectively degenerates to =
JavaScript-like scoping rules where any undefined identifier becomes a glob=
al variable upon use.)</div>

</div></blockquote><div><br></div><div>Quotation marks don&#39;t add any ex=
tra safety. =C2=A0You can just as easily make a typo inside quotation marks=
 as outside. =C2=A0anyname isn&#39;t only for use at global namespace scope=
, it&#39;s a general mechanism that works in any scope and for any kind of =
template entity.</div>
</div></div></div></div></blockquote><div><br></div><div>The safety is to p=
rotect folks who don=E2=80=99t intend to use the anyname feature at all. Th=
is is what happens in JavaScript: misspell any unqualified identifier lvalu=
e and it helpfully generates a global variable. (The misfeature is disabled=
 in =E2=80=9Cstrict mode=E2=80=9D IIRC.)</div>
<div><br></div><div>Templates currently may only be defined at namespace or=
 class scope, and there are no nonstatic member variable templates. I guess=
 having all misspellings map to unintended types is slightly less dangerous=
 than global variables, but it would still be banned by any reasonable styl=
e policy, and disused by every library that intends compatibility with othe=
r libraries.</div>
</div><div></div></div></blockquote></div></div><div><br></div><div>Unquali=
fied name lookup will only find an anyname template if one is in one of the=
 scopes searched. =C2=A0So if you don&#39;t want that, don&#39;t put one th=
ere. =C2=A0Yes, library authors need to coordinate with program authors on =
what language features they use and how.</div>
<div><br></div><div>Also, as a template you can place constraints on what t=
he name can be at compile-time as a predicate/concept on the name or other =
factors. =C2=A0You can also store the text and check it at run-time.</div><=
div>
<br></div><div>You did watch Redl&#39;s presentation right? =C2=A0<a href=
=3D"https://www.youtube.com/embed/Gy9ITl1AWRY" target=3D"_blank" style=3D"f=
ont-size:13.333333969116211px;font-family:arial,sans-serif">https://www.you=
tube.com/embed/Gy9ITl1AWRY</a></div>
<div><br></div><div>Yes, the anyname design needs some work on non-static m=
ember variables. =C2=A0There is ongoing work on operator. (current work, no=
t Redls) that I anticipate to complement anyname. =C2=A0I&#39;m still worki=
ng out some of the details.</div>
<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 />

--001a1135fd5c16bd7e0500f57b50--

.


Author: David Krauss <potswa@gmail.com>
Date: Tue, 19 Aug 2014 14:21:29 +0800
Raw View
--Apple-Mail=_95210935-314D-4756-95E7-1DBA5229D620
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8


On 2014=E2=80=9308=E2=80=9319, at 1:49 PM, Andrew Tomazos <andrewtomazos@gm=
ail.com> wrote:

> It's similar in the sense that it is passing text as a char pack.  The te=
xt for a string literal operator template comes from a string literal token=
..  The text in anyname comes from an identifier token.
> =20
> The char pack version of string literals was not approved by ewg.  This i=
s issue 66: http://wg21.cmeerw.net/ewg/issue66

That=E2=80=99s a shame. I would have proposed it differently, though, to co=
incide with integer literal operator templates, which work because the digi=
ts are all =E2=80=9Craw.=E2=80=9D Given that string metaprocessing is in th=
e works, it would provide the means to translate escape sequences into what=
ever format a template accepts. But letting template specialization depend =
on the execution character set is dangerous.

Note that you need to account for this in your proposal as well, because id=
entifiers may also contain UCNs, but UCNs do not have a normalized format. =
An extended character could translate to a 4-digit capitalized UCN on syste=
m =F0=9D=94=84 and an 8-digit lowercase UCN on system =F0=9D=94=85. This cr=
eates a source of ABI incompatibilities when they get plugged into literal =
operator templates.

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

--Apple-Mail=_95210935-314D-4756-95E7-1DBA5229D620
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;"><br><div><div>On 2014=E2=80=
=9308=E2=80=9319, at 1:49 PM, Andrew Tomazos &lt;<a href=3D"mailto:andrewto=
mazos@gmail.com">andrewtomazos@gmail.com</a>&gt; wrote:</div><br class=3D"A=
pple-interchange-newline"><blockquote type=3D"cite"><div dir=3D"ltr"><div c=
lass=3D"gmail_extra"><div class=3D"gmail_quote"><div>It's similar in the se=
nse that it is passing text as a char pack. &nbsp;The text for a string lit=
eral operator template comes from a string literal token. &nbsp;The text in=
 anyname comes from an identifier token.</div>
<div>&nbsp;</div><div>The char pack version of string literals was not appr=
oved by ewg. &nbsp;This is issue 66:&nbsp;<a href=3D"http://wg21.cmeerw.net=
/ewg/issue66">http://wg21.cmeerw.net/ewg/issue66</a></div></div></div></div=
></blockquote><br></div><div>That=E2=80=99s a shame. I would have proposed =
it differently, though, to coincide with integer literal operator templates=
, which work because the digits are all =E2=80=9Craw.=E2=80=9D Given that s=
tring metaprocessing is in the works, it would provide the means to transla=
te escape sequences into whatever format a template accepts. But letting te=
mplate specialization depend on the execution character set is dangerous.</=
div><div><br></div><div>Note that you need to account for this in your prop=
osal as well, because identifiers may also contain UCNs, but UCNs do not ha=
ve a normalized format. An extended character could translate to a 4-digit =
capitalized UCN on system =F0=9D=94=84 and an 8-digit lowercase UCN on syst=
em =F0=9D=94=85. This creates a source of ABI incompatibilities when they g=
et plugged into literal operator templates.</div><br></body></html>

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

--Apple-Mail=_95210935-314D-4756-95E7-1DBA5229D620--

.


Author: Andrew Tomazos <andrewtomazos@gmail.com>
Date: Tue, 19 Aug 2014 08:32:26 +0200
Raw View
--047d7b1118fdad80b20500f5a62c
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Tue, Aug 19, 2014 at 8:21 AM, David Krauss <potswa@gmail.com> wrote:

>
> On 2014=E2=80=9308=E2=80=9319, at 1:49 PM, Andrew Tomazos <andrewtomazos@=
gmail.com> wrote:
>
> It's similar in the sense that it is passing text as a char pack.  The
> text for a string literal operator template comes from a string literal
> token.  The text in anyname comes from an identifier token.
>
> The char pack version of string literals was not approved by ewg.  This i=
s
> issue 66: http://wg21.cmeerw.net/ewg/issue66
>
>
> That=E2=80=99s a shame. I would have proposed it differently, though, to =
coincide
> with integer literal operator templates, which work because the digits ar=
e
> all =E2=80=9Craw.=E2=80=9D Given that string metaprocessing is in the wor=
ks, it would
> provide the means to translate escape sequences into whatever format a
> template accepts. But letting template specialization depend on the
> execution character set is dangerous.
>
> Note that you need to account for this in your proposal as well, because
> identifiers may also contain UCNs, but UCNs do not have a normalized
> format. An extended character could translate to a 4-digit capitalized UC=
N
> on system =F0=9D=94=84 and an 8-digit lowercase UCN on system =F0=9D=94=
=85. This creates a
> source of ABI incompatibilities when they get plugged into literal operat=
or
> templates.
>
> Which proposal?  anyname or N4121?

In all cases (these proposals and reflection) I define it as hardcoded to
UTF-8 encoding, not the execution encoding.  UCNs in identifiers are also
explicitly stated to be decoded to their code point, then encoded into
UTF-8.  There is a few paragraphs about the design rationale how we came to
this in N3815, the decision was also accepted by SG7.

For user-defined string literals, I expect the encoding is whatever the
code units of the string literal would be at run-time.  String literals
have UCNs decoded in translation phase 5.

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

--047d7b1118fdad80b20500f5a62c
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><br><div class=3D"gmail=
_quote">On Tue, Aug 19, 2014 at 8:21 AM, David Krauss <span dir=3D"ltr">&lt=
;<a href=3D"mailto:potswa@gmail.com" target=3D"_blank">potswa@gmail.com</a>=
&gt;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div style=3D"word-wrap:break-word"><br><div=
><div class=3D""><div>On 2014=E2=80=9308=E2=80=9319, at 1:49 PM, Andrew Tom=
azos &lt;<a href=3D"mailto:andrewtomazos@gmail.com" target=3D"_blank">andre=
wtomazos@gmail.com</a>&gt; wrote:</div>
<br></div><div class=3D""><blockquote type=3D"cite"><div dir=3D"ltr"><div c=
lass=3D"gmail_extra"><div class=3D"gmail_quote"><div>It&#39;s similar in th=
e sense that it is passing text as a char pack. =C2=A0The text for a string=
 literal operator template comes from a string literal token. =C2=A0The tex=
t in anyname comes from an identifier token.</div>

<div>=C2=A0</div><div>The char pack version of string literals was not appr=
oved by ewg. =C2=A0This is issue 66:=C2=A0<a href=3D"http://wg21.cmeerw.net=
/ewg/issue66" target=3D"_blank">http://wg21.cmeerw.net/ewg/issue66</a></div=
></div></div></div>
</blockquote><br></div></div><div>That=E2=80=99s a shame. I would have prop=
osed it differently, though, to coincide with integer literal operator temp=
lates, which work because the digits are all =E2=80=9Craw.=E2=80=9D Given t=
hat string metaprocessing is in the works, it would provide the means to tr=
anslate escape sequences into whatever format a template accepts. But letti=
ng template specialization depend on the execution character set is dangero=
us.</div>
<div><br></div><div>Note that you need to account for this in your proposal=
 as well, because identifiers may also contain UCNs, but UCNs do not have a=
 normalized format. An extended character could translate to a 4-digit capi=
talized UCN on system =F0=9D=94=84 and an 8-digit lowercase UCN on system =
=F0=9D=94=85. This creates a source of ABI incompatibilities when they get =
plugged into literal operator templates.</div>
<div><br></div></div></blockquote><div>Which proposal? =C2=A0anyname or N41=
21?</div><div><br></div><div>In all cases (these proposals and reflection) =
I define it as hardcoded to UTF-8 encoding, not the execution encoding. =C2=
=A0UCNs in identifiers are also explicitly stated to be decoded to their co=
de point, then encoded into UTF-8. =C2=A0There is a few paragraphs about th=
e design rationale how we came to this in N3815, the decision was also acce=
pted by SG7.</div>
<div><br></div><div>For user-defined string literals, I expect the encoding=
 is whatever the code units of the string literal would be at run-time. =C2=
=A0String literals have UCNs decoded in translation phase 5.</div><div><br>=
</div>
<div><br></div></div></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 />

--047d7b1118fdad80b20500f5a62c--

.


Author: David Krauss <potswa@gmail.com>
Date: Tue, 19 Aug 2014 14:50:40 +0800
Raw View
--Apple-Mail=_EA0FABF8-3733-43E9-AB2D-E2F1E14AAFBC
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-1


On 2014-08-19, at 2:32 PM, Andrew Tomazos <andrewtomazos@gmail.com> wrote:

> Which proposal?  anyname or N4121?

Anyname. I didn't read N4121 yet but I'd expect compile-time string literal=
s to work the same as runtime. The problem only crops up when strings enter=
 the type system, which I assume N4121 doesn't do.

> In all cases (these proposals and reflection) I define it as hardcoded to=
 UTF-8 encoding, not the execution encoding.  UCNs in identifiers are also =
explicitly stated to be decoded to their code point, then encoded into UTF-=
8.  There is a few paragraphs about the design rationale how we came to thi=
s in N3815, the decision was also accepted by SG7.

Sounds like the most reasonable way.

> For user-defined string literals, I expect the encoding is whatever the c=
ode units of the string literal would be at run-time.  String literals have=
 UCNs decoded in translation phase 5.

No "would" about it. User-defined string literals simply pass an underlying=
 ordinary string literal to a function. The underlying string literal may s=
pecify a width/encoding prefix, and the literal operator may require such b=
y taking e.g. a char32_t* parameter type, but unfortunately the type system=
 does not discriminate UTF-8 from other local narrow encodings.


On 2014-08-19, at 2:20 PM, Andrew Tomazos <andrewtomazos@gmail.com> wrote:

> Unqualified name lookup will only find an anyname template if one is in o=
ne of the scopes searched.  So if you don't want that, don't put one there.=
  Yes, library authors need to coordinate with program authors on what lang=
uage features they use and how.

Where else are you going to put it? Finding a literal or anyname operator b=
y qualified lookup rather defeats the purpose.

A context without diagnosis of undefined identifiers is likely to be relega=
ted to use as an EDSL sandbox. Is that a good trade-off against typing the =
quotes?

> Also, as a template you can place constraints on what the name can be at =
compile-time as a predicate/concept on the name or other factors. =20

Libraries can't reasonably coordinate their grammars to be mutually exclusi=
ve. It would just come around to identifying suffixes, just like ud-suffix.=
 Also, SFINAE (or any alternative such as with Concepts) requires the compi=
ler to attempt interpretation through all possible templates, to make sure =
all fail (by a SFINAE friendly soft error) but exactly one.

> You can also store the text and check it at run-time.
>=20
> You did watch Redl's presentation right?  https://www.youtube.com/embed/G=
y9ITl1AWRY
>=20
> Yes, the anyname design needs some work on non-static member variables.  =
There is ongoing work on operator. (current work, not Redls) that I anticip=
ate to complement anyname.  I'm still working out some of the details.

Use in a member lookup context seems much safer. I'm still queazy about mak=
ing it look exactly like a regular member access, though.

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

--Apple-Mail=_EA0FABF8-3733-43E9-AB2D-E2F1E14AAFBC
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=ISO-8859-1

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 2014&=
ndash;08&ndash;19, at 2:32 PM, Andrew Tomazos &lt;<a href=3D"mailto:andrewt=
omazos@gmail.com">andrewtomazos@gmail.com</a>&gt; wrote:</div><br class=3D"=
Apple-interchange-newline"><blockquote type=3D"cite"><div dir=3D"ltr">Which=
 proposal? &nbsp;anyname or N4121?</div></blockquote><div><br></div>Anyname=
.. I didn&rsquo;t read N4121 yet but I&rsquo;d expect compile-time string li=
terals to work the same as runtime. The problem only crops up when strings =
enter the type system, which I assume N4121 doesn&rsquo;t do.</div><div><br=
><blockquote type=3D"cite"><div dir=3D"ltr"><div class=3D"gmail_extra"><div=
 class=3D"gmail_quote"><div>In all cases (these proposals and reflection) I=
 define it as hardcoded to UTF-8 encoding, not the execution encoding. &nbs=
p;UCNs in identifiers are also explicitly stated to be decoded to their cod=
e point, then encoded into UTF-8. &nbsp;There is a few paragraphs about the=
 design rationale how we came to this in N3815, the decision was also accep=
ted by SG7.</div></div></div></div></blockquote><div><br></div>Sounds like =
the most reasonable way.</div><div><br><blockquote type=3D"cite"><div dir=
=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">
<div>For user-defined string literals, I expect the encoding is whatever th=
e code units of the string literal would be at run-time. &nbsp;String liter=
als have UCNs decoded in translation phase 5.</div></div></div></div></bloc=
kquote><br></div><div>No &ldquo;would&rdquo; about it. User-defined string =
literals simply pass an underlying ordinary string literal to a function. T=
he underlying string literal may specify a width/encoding prefix, and the l=
iteral operator may require such by taking e.g. a <font face=3D"Courier">ch=
ar32_t*</font> parameter type, but unfortunately the type system does not d=
iscriminate UTF-8 from other local narrow encodings.</div><br><div><br></di=
v><div><div><div>On 2014&ndash;08&ndash;19, at 2:20 PM, Andrew Tomazos &lt;=
<a href=3D"mailto:andrewtomazos@gmail.com">andrewtomazos@gmail.com</a>&gt; =
wrote:</div><br class=3D"Apple-interchange-newline"><blockquote type=3D"cit=
e"><div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">U=
nqualified name lookup will only find an anyname template if one is in one =
of the scopes searched. &nbsp;So if you don't want that, don't put one ther=
e. &nbsp;Yes, library authors need to coordinate with program authors on wh=
at language features they use and how.</div></div></div></blockquote><div><=
br></div><div>Where else are you going to put it? Finding a literal or anyn=
ame operator by qualified lookup rather defeats the purpose.</div><div><br>=
</div><div>A context without diagnosis of undefined identifiers is likely t=
o be relegated to use as an EDSL sandbox. Is that a good trade-off against =
typing the quotes?</div><br><blockquote type=3D"cite"><div dir=3D"ltr">Also=
, as a template you can place constraints on what the name can be at compil=
e-time as a predicate/concept on the name or other factors. &nbsp;</div></b=
lockquote><div><br></div><div>Libraries can&rsquo;t reasonably coordinate t=
heir grammars to be mutually exclusive. It would just come around to identi=
fying suffixes, just like&nbsp;<i>ud-suffix</i>. Also, SFINAE (or any alter=
native such as with Concepts) requires the compiler to attempt interpretati=
on through all possible templates, to make sure all fail (by a SFINAE frien=
dly soft error) but exactly one.</div><br><blockquote type=3D"cite"><div di=
r=3D"ltr"><div>You can also store the text and check it at run-time.</div><=
div><br></div><div>You did watch Redl's presentation right? &nbsp;<a href=
=3D"https://www.youtube.com/embed/Gy9ITl1AWRY" target=3D"_blank" style=3D"f=
ont-size: 13.333333969116211px; font-family: arial, sans-serif;">https://ww=
w.youtube.com/embed/Gy9ITl1AWRY</a></div><div><br></div><div>Yes, the anyna=
me design needs some work on non-static member variables. &nbsp;There is on=
going work on operator. (current work, not Redls) that I anticipate to comp=
lement anyname. &nbsp;I'm still working out some of the details.</div></div=
></blockquote><div><br></div></div>Use in a member lookup context seems muc=
h safer. I&rsquo;m still queazy about making it look exactly like a regular=
 member access, though.</div><div><br></div></body></html>

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

--Apple-Mail=_EA0FABF8-3733-43E9-AB2D-E2F1E14AAFBC--

.


Author: Andrew Tomazos <andrewtomazos@gmail.com>
Date: Tue, 19 Aug 2014 09:17:41 +0200
Raw View
--089e01183b70746c560500f6485b
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Tue, Aug 19, 2014 at 8:50 AM, David Krauss <potswa@gmail.com> wrote:

>
> On 2014=E2=80=9308=E2=80=9319, at 2:32 PM, Andrew Tomazos <andrewtomazos@=
gmail.com> wrote:
>
> Which proposal?  anyname or N4121?
>
>
> Anyname. I didn=E2=80=99t read N4121 yet but I=E2=80=99d expect compile-t=
ime string
> literals to work the same as runtime. The problem only crops up when
> strings enter the type system, which I assume N4121 doesn=E2=80=99t do.
>
> In all cases (these proposals and reflection) I define it as hardcoded to
> UTF-8 encoding, not the execution encoding.  UCNs in identifiers are also
> explicitly stated to be decoded to their code point, then encoded into
> UTF-8.  There is a few paragraphs about the design rationale how we came =
to
> this in N3815, the decision was also accepted by SG7.
>
>
> Sounds like the most reasonable way.
>
> For user-defined string literals, I expect the encoding is whatever the
> code units of the string literal would be at run-time.  String literals
> have UCNs decoded in translation phase 5.
>
>
> No =E2=80=9Cwould=E2=80=9D about it. User-defined string literals simply =
pass an
> underlying ordinary string literal to a function. The underlying string
> literal may specify a width/encoding prefix, and the literal operator may
> require such by taking e.g. a char32_t* parameter type, but unfortunately
> the type system does not discriminate UTF-8 from other local narrow
> encodings.
>
>
> On 2014=E2=80=9308=E2=80=9319, at 2:20 PM, Andrew Tomazos <andrewtomazos@=
gmail.com> wrote:
>
> Unqualified name lookup will only find an anyname template if one is in
> one of the scopes searched.  So if you don't want that, don't put one
> there.  Yes, library authors need to coordinate with program authors on
> what language features they use and how.
>
>
> Where else are you going to put it? Finding a literal or anyname operator
> by qualified lookup rather defeats the purpose.
>

?  In a namespace or class scope...

namespace N
{
    template<char... name>
    using __anyname__ =3D whatever;
}

foo bar; // error: foo not found

N::foo bar; // ok, foo found type is N::__anyname__<'f','o','o>

void f()
{
    using namespace N;

    foo bar; // ok, foo found again
}

A context without diagnosis of undefined identifiers is likely to be
> relegated to use as an EDSL sandbox. Is that a good trade-off against
> typing the quotes?
>
> Also, as a template you can place constraints on what the name can be at
> compile-time as a predicate/concept on the name or other factors.
>
>
> Libraries can=E2=80=99t reasonably coordinate their grammars to be mutual=
ly
> exclusive. It would just come around to identifying suffixes, just like
> *ud-suffix*. Also, SFINAE (or any alternative such as with Concepts)
> requires the compiler to attempt interpretation through all possible
> templates, to make sure all fail (by a SFINAE friendly soft error) but
> exactly one.
>
> You can also store the text and check it at run-time.
>
> You did watch Redl's presentation right?
> https://www.youtube.com/embed/Gy9ITl1AWRY
>
> Yes, the anyname design needs some work on non-static member variables.
>  There is ongoing work on operator. (current work, not Redls) that I
> anticipate to complement anyname.  I'm still working out some of the
> details.
>
>
> Use in a member lookup context seems much safer. I=E2=80=99m still queazy=
 about
> making it look exactly like a regular member access, though.
>
>  --
>
> ---
> 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/.
>

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

--089e01183b70746c560500f6485b
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><br><div class=3D"gmail=
_quote">On Tue, Aug 19, 2014 at 8:50 AM, David Krauss <span dir=3D"ltr">&lt=
;<a href=3D"mailto:potswa@gmail.com" target=3D"_blank">potswa@gmail.com</a>=
&gt;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div style=3D"word-wrap:break-word"><br><div=
><div class=3D""><div>On 2014=E2=80=9308=E2=80=9319, at 2:32 PM, Andrew Tom=
azos &lt;<a href=3D"mailto:andrewtomazos@gmail.com" target=3D"_blank">andre=
wtomazos@gmail.com</a>&gt; wrote:</div>
<br><blockquote type=3D"cite"><div dir=3D"ltr">Which proposal? =C2=A0anynam=
e or N4121?</div></blockquote><div><br></div></div>Anyname. I didn=E2=80=99=
t read N4121 yet but I=E2=80=99d expect compile-time string literals to wor=
k the same as runtime. The problem only crops up when strings enter the typ=
e system, which I assume N4121 doesn=E2=80=99t do.</div>
<div><div class=3D""><br><blockquote type=3D"cite"><div dir=3D"ltr"><div cl=
ass=3D"gmail_extra"><div class=3D"gmail_quote"><div>In all cases (these pro=
posals and reflection) I define it as hardcoded to UTF-8 encoding, not the =
execution encoding. =C2=A0UCNs in identifiers are also explicitly stated to=
 be decoded to their code point, then encoded into UTF-8. =C2=A0There is a =
few paragraphs about the design rationale how we came to this in N3815, the=
 decision was also accepted by SG7.</div>
</div></div></div></blockquote><div><br></div></div>Sounds like the most re=
asonable way.</div><div class=3D""><div><br><blockquote type=3D"cite"><div =
dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">
<div>For user-defined string literals, I expect the encoding is whatever th=
e code units of the string literal would be at run-time. =C2=A0String liter=
als have UCNs decoded in translation phase 5.</div></div></div></div></bloc=
kquote>
<br></div></div><div>No =E2=80=9Cwould=E2=80=9D about it. User-defined stri=
ng literals simply pass an underlying ordinary string literal to a function=
.. The underlying string literal may specify a width/encoding prefix, and th=
e literal operator may require such by taking e.g. a <font face=3D"Courier"=
>char32_t*</font> parameter type, but unfortunately the type system does no=
t discriminate UTF-8 from other local narrow encodings.</div>
<br><div><br></div><div><div><div class=3D""><div>On 2014=E2=80=9308=E2=80=
=9319, at 2:20 PM, Andrew Tomazos &lt;<a href=3D"mailto:andrewtomazos@gmail=
..com" target=3D"_blank">andrewtomazos@gmail.com</a>&gt; wrote:</div><br><bl=
ockquote type=3D"cite">
<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">Unqu=
alified name lookup will only find an anyname template if one is in one of =
the scopes searched. =C2=A0So if you don&#39;t want that, don&#39;t put one=
 there. =C2=A0Yes, library authors need to coordinate with program authors =
on what language features they use and how.</div>
</div></div></blockquote><div><br></div></div><div>Where else are you going=
 to put it? Finding a literal or anyname operator by qualified lookup rathe=
r defeats the purpose.</div></div></div></div></blockquote><div><br></div>
<div>? =C2=A0In a namespace or class scope...</div><div><br></div><div>name=
space N</div><div>{</div><div>=C2=A0 =C2=A0 template&lt;char... name&gt;</d=
iv><div>=C2=A0 =C2=A0 using __anyname__ =3D whatever;</div><div>}</div><div=
><br></div><div>foo bar; // error: foo not found</div>
<div><br></div><div>N::foo bar; // ok, foo found type is N::__anyname__&lt;=
&#39;f&#39;,&#39;o&#39;,&#39;o&gt;</div><div><br></div><div>void f()</div><=
div>{</div><div>=C2=A0 =C2=A0 using namespace N;</div><div><br></div><div>=
=C2=A0 =C2=A0 foo bar; // ok, foo found again</div>
<div>}</div><div><br></div><blockquote class=3D"gmail_quote" style=3D"margi=
n:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style=3D"wor=
d-wrap:break-word"><div><div><div></div><div>A context without diagnosis of=
 undefined identifiers is likely to be relegated to use as an EDSL sandbox.=
 Is that a good trade-off against typing the quotes?</div>
<div class=3D""><br></div></div></div></div></blockquote><blockquote class=
=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd=
ing-left:1ex"><div style=3D"word-wrap:break-word"><div><div><div class=3D""=
><blockquote type=3D"cite">
<div dir=3D"ltr">Also, as a template you can place constraints on what the =
name can be at compile-time as a predicate/concept on the name or other fac=
tors. =C2=A0</div></blockquote><div><br></div></div><div>Libraries can=E2=
=80=99t reasonably coordinate their grammars to be mutually exclusive. It w=
ould just come around to identifying suffixes, just like=C2=A0<i>ud-suffix<=
/i>. Also, SFINAE (or any alternative such as with Concepts) requires the c=
ompiler to attempt interpretation through all possible templates, to make s=
ure all fail (by a SFINAE friendly soft error) but exactly one.</div>
<div class=3D""><br><blockquote type=3D"cite"><div dir=3D"ltr"><div>You can=
 also store the text and check it at run-time.</div><div><br></div><div>You=
 did watch Redl&#39;s presentation right? =C2=A0<a href=3D"https://www.yout=
ube.com/embed/Gy9ITl1AWRY" style=3D"font-size:13.333333969116211px;font-fam=
ily:arial,sans-serif" target=3D"_blank">https://www.youtube.com/embed/Gy9IT=
l1AWRY</a></div>
<div><br></div><div>Yes, the anyname design needs some work on non-static m=
ember variables. =C2=A0There is ongoing work on operator. (current work, no=
t Redls) that I anticipate to complement anyname. =C2=A0I&#39;m still worki=
ng out some of the details.</div>
</div></blockquote><div><br></div></div></div>Use in a member lookup contex=
t seems much safer. I=E2=80=99m still queazy about making it look exactly l=
ike a regular member access, though.</div><div><br></div></div><div class=
=3D"HOEnZb">
<div class=3D"h5">

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

--089e01183b70746c560500f6485b--

.


Author: David Krauss <potswa@gmail.com>
Date: Tue, 19 Aug 2014 15:44:42 +0800
Raw View
On 2014-08-19, at 3:17 PM, Andrew Tomazos <andrewtomazos@gmail.com> wrote:

> ?  In a namespace or class scope...
>
> namespace N
> {
>     template<char... name>
>     using __anyname__ = whatever;
> }
>
> foo bar; // error: foo not found
>
> N::foo bar; // ok, foo found type is N::__anyname__<'f','o','o>

Ah, thx. That wasn't obvious from before.

--

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

.


Author: tl <timlenertz@gmail.com>
Date: Tue, 19 Aug 2014 06:56:39 -0700 (PDT)
Raw View
------=_Part_124_1722795477.1408456599478
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

That way __anyname__ could only be used for member/non-member types, but=20
not for functions/attributes. Maybe something like this would be useful=20
(for example for a database abstraction layer):

class database_table {
  ...
public:
  template<std::size_t N>
  database_field_accessor __anyname__(std::string_literal<N> name) {
    return database_field_accessor(*this, name.to_string());
  }
};

where database_field_accessor would define a conversion operator and=20
assignment operator, and hold a pointer to the database_table.
To simulate member functions it would implement operator(). The compiler=20
would probably optimize away the creation of a temporary=20
database_field_accessor object. So this would be similar to the way=20
properties can be  simulated currently.

Or when it becomes possible
template<std::size_t N, std::string_literal<N> Name>
database_field_accessor __anyname__()

That way constexpr functions and SFINAE could be used to analyse the name=
=20
at compile time, for example to only accept those with a certain prefix.



On Tuesday, August 19, 2014 9:44:47 AM UTC+2, David Krauss wrote:
>
>
> On 2014=E2=80=9308=E2=80=9319, at 3:17 PM, Andrew Tomazos <andrew...@gmai=
l.com=20
> <javascript:>> wrote:=20
>
> > ?  In a namespace or class scope...=20
> >=20
> > namespace N=20
> > {=20
> >     template<char... name>=20
> >     using __anyname__ =3D whatever;=20
> > }=20
> >=20
> > foo bar; // error: foo not found=20
> >=20
> > N::foo bar; // ok, foo found type is N::__anyname__<'f','o',=E2=80=99o>=
=20
>
> Ah, thx. That wasn=E2=80=99t obvious from before.=20
>
>

--=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_124_1722795477.1408456599478
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>That way __anyname__ could only be used for member/no=
n-member types, but not for functions/attributes. Maybe something like this=
 would be useful (for example for a database abstraction layer):</div><div>=
<br></div><div><div class=3D"prettyprint" style=3D"background-color: rgb(25=
0, 250, 250); border: 1px solid rgb(187, 187, 187); word-wrap: break-word;"=
><code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">class</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> database_table </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br>&nbsp; </span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">...</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">public</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br>&nbsp; </span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">template</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">&lt;</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify">size_t N</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; database=
_field_accessor</span><font color=3D"#666600"><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> __anyname__</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">std</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">string_literal</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">&lt;</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">N</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&g=
t;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> name</s=
pan><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"styled-by-prettify">{</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br></span></font><span style=3D"color: =
#000;" class=3D"styled-by-prettify">&nbsp; &nbsp; </span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">return</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> database_field_accessor</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">(*</span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">this</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> name</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">to_string</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">());</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br>&nbsp; </span><font color=3D"#666600"><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">}</span></font><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">};</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br></span></div></code></div><div><br></div>where&nbsp;<s=
pan style=3D"color: rgb(0, 0, 0); font-family: monospace; background-color:=
 rgb(250, 250, 250);">database_field_accessor&nbsp;</span>would define a co=
nversion operator and assignment operator, and hold a pointer to the databa=
se_table.</div><div>To simulate member functions it would implement operato=
r(). The compiler would probably optimize away the creation of a temporary =
database_field_accessor object. So this would be similar to the way propert=
ies can be &nbsp;simulated currently.</div><div><br></div><div>Or when it b=
ecomes possible</div><div><div class=3D"prettyprint" style=3D"background-co=
lor: rgb(250, 250, 250); border: 1px solid rgb(187, 187, 187); word-wrap: b=
reak-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><font=
 color=3D"#660066"><span style=3D"color: #008;" class=3D"styled-by-prettify=
">template</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">std</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">size_t N</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=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">string_literal</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">N</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettif=
y">Name</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt=
;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>datab=
ase_field_accessor __anyname__</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">()</span></font></div></code></div><div><br></div>That =
way constexpr functions and SFINAE could be used to analyse the name at com=
pile time, for example to only accept those with a certain prefix.<br><br><=
/div><br><br>On Tuesday, August 19, 2014 9:44:47 AM UTC+2, David Krauss wro=
te:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;=
border-left: 1px #ccc solid;padding-left: 1ex;">
<br>On 2014=E2=80=9308=E2=80=9319, at 3:17 PM, Andrew Tomazos &lt;<a href=
=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"206itkcyeQ8J" o=
nmousedown=3D"this.href=3D'javascript:';return true;" onclick=3D"this.href=
=3D'javascript:';return true;">andrew...@gmail.com</a>&gt; wrote:
<br>
<br>&gt; ? &nbsp;In a namespace or class scope...
<br>&gt;=20
<br>&gt; namespace N
<br>&gt; {
<br>&gt; &nbsp; &nbsp; template&lt;char... name&gt;
<br>&gt; &nbsp; &nbsp; using __anyname__ =3D whatever;
<br>&gt; }
<br>&gt;=20
<br>&gt; foo bar; // error: foo not found
<br>&gt;=20
<br>&gt; N::foo bar; // ok, foo found type is N::__anyname__&lt;'f','o',=E2=
=80=99o&gt;
<br>
<br>Ah, thx. That wasn=E2=80=99t obvious from before.
<br>
<br></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_124_1722795477.1408456599478--

.