<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 11 January 2014 00:31, John Colvin <span dir="ltr"><<a href="mailto:john.loughran.colvin@gmail.com" target="_blank">john.loughran.colvin@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Friday, 10 January 2014 at 14:28:09 UTC, John Colvin wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
On Friday, 10 January 2014 at 14:02:21 UTC, Manu wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 10 January 2014 00:07, Manu <<a href="mailto:turkeyman@gmail.com" target="_blank">turkeyman@gmail.com</a>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This works fine:<br>
 string x = find("Hello", 'H');<br>
<br>
This doesn't:<br>
 string y = find(retro("Hello"), 'H');<br>
 > Error: cannot implicitly convert expression (find(retro("Hello"),<br>
'H')) of type Result!() to string<br>
<br>
Is that wrong? That seems to be how the docs suggest it should be used.<br>
<br>
On a side note, am I the only one that finds std.algorithm/std.range/etc<br>
for string processing really obtuse?<br>
I can rarely understand the error messages, so say it's better than STL is<br>
optimistic.<br>
Using std.algorithm and std.range to do string manipulation feels really<br>
lame to me.<br>
I hate looking through the docs of 3-4 modules to understand the complete<br>
set of useful string operations (std.string, std.uni, std.algorithm,<br>
std.range... at least).<br>
I also find the names of the generic algorithms are often unrelated to the<br>
name of the string operation.<br>
My feeling is, everyone is always on about how cool D is at string, but<br>
other than 'char[]', and the builtin slice operator, I feel really<br>
unproductive whenever I do any heavy string manipulation in D.<br>
I also hate that I need to import at least 4-5 modules to do anything<br>
useful with strings... I feel my program bloating and cringe with every<br>
gigantic import that sources exactly one symbol.<br>
<br>
</blockquote><div class="im">
<br>
I won't start another annoying thread.<br>
<br>
What's the go with popFront()... it returns nothing?<br>
I almost always want to pop and return the front element. I can't find a<br>
function to do that... have I missed something again?<br>
</div></blockquote>
<br>
Popping the front off a range doesn't necessarily require the work needed to return the front itself. A trivial example would be a range of e^n : popFront just incrememnts n but calculating front requires the relatively expensive exponentiation.<br>

<br>
Also, it is legal call popFront on a range with only one element remaining, leaving it empty. It is not valid to then look at the front.<br>
<br>
You want both at once? take a look at the various std.range.take*<br>
</blockquote>
<br>
or if you want something short and simple, define a free function:<br>
auto popFrontRet(R)(ref R range)<br>
    if(isInputRange!R)<br>
{<br>
    range.popFront();<br>
    assert(!range.empty);<br>
    return range.front;<br>
}<br>
</blockquote></div><br></div><div class="gmail_extra">This is what I've done. I'm just surprised that such an obvious function doesn't exist, and suspect I was just retarded at phobos again.</div><div class="gmail_extra">
Having a function that does this is kinda important to simplify lots of expressions that otherwise need to be broken out across a bunch of lines.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Does nobody see this coming up in their code? I have it basically every time I use ranges, and as usual, surprised others don't feel the same way.</div>
</div>