<div dir="ltr">2013/3/29 Andrej Mitrovic <span dir="ltr"><<a href="mailto:andrej.mitrovich@gmail.com" target="_blank">andrej.mitrovich@gmail.com</a>></span><br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="im">On 3/29/13, kenji hara <<a href="mailto:k.hara.pg@gmail.com">k.hara.pg@gmail.com</a>> wrote:<br>
> <a href="http://wiki.dlang.org/DIP32" target="_blank">http://wiki.dlang.org/DIP32</a><br>
><br>
> Kenji Hara<br>
><br>
<br>
</div><quote><br>
And, this syntax (currently it is not enough documented)<br>
foreach (x, y; zip([1,2,3], ["a","b","c"])) {}<br>
</quote><br>
<br>
Well that kinda sucks, I was just getting used to this syntax..But for<br>
me it it was too magical to begin with, so I have no real complaints.<br>
<br>
<quote><br>
if (auto {1, y} = tup) {<br>
// If the first element of tup (tup[0]) is equal to 1,<br>
// y captures the second element of tup (tup[1]).<br>
}<br>
</quote><br>
<br>
That looks like black magic to me.<br>
<br>
<quote><br>
int x = 1;<br>
if (auto {$x, y} = coord) { ... }<br>
// If the first element of coord is equal to 1 (== x), 'then'<br>
statement wil be evaluated.<br>
</quote><br>
<br>
I really don't think we need this magic.. It feels like D and Perl had<br>
lots of booze and made it to the mile-high club, and one of them got<br>
pregnant.<br>
<br>
I just thinks this adds way too many features at once. I'd argue we<br>
should take it slow and start with some basic ability to define and<br>
unpack tuples, and then gradually add these other features *if*<br>
they're really wanted.<br>
<br>
The new meaning of $ and $var and literals in if statements and "...",<br>
is just too much for me to take.<br>
</blockquote></div><br></div><div class="gmail_extra" style>I wrote about it to encourage discussions.</div><div><br></div><div style>I can agree that $identifier looks weird, but a feature to do it is*necessary*.</div><div style>
<br></div><div style>When you create a pattern for matching, there is two cases.</div><div style>- All value part can be represented by literal.</div><div style>- Some values would be made in runtime.</div><div><br></div>
<div style>bool testMatch(T)(int first_value, T tup) {</div><div style> if (auto {first_value, ...} = tup) { return true; } else { return false; }</div><div style> // first_value should be replaced to the given function argument, rather than capturing tup[0]</div>
<div style>}</div><div style>assert(testMatch(1, {1, 2, 3}) == true);</div><div style>assert(testMatch(2, {1, 2, 3}) == false);<br></div><div><br></div><div style>To distinct the capturing and evaluated value, var and $var is necessary.</div>
<div><br></div><div style>Syntax for the feature is still debatable.</div><div style><br></div><div class="gmail_extra" style>Kenji Hara</div></div>