« first day (1806 days earlier)      last day (1686 days later) » 

5:08 AM
@SébastienRenauld You mean it wouldn't be very useful ? The question itself seems reasonable. The problem is you don't gain a lot without compile time checks
 
 
5 hours later…
10:37 AM
I don't see how panic by default is the right solution there
 
just like you want panic on a read out of array, you may want to stop all operations before doing something worse
But I agree it's not much useful.
 
should a validation error result in a hard fault?
 
10:55 AM
it is for other similar cases, like u:usize = 0; u-=1
Personally I'd use dependant types with hard checks (maybe disabled in non debug for perf reasons)
But I won't pretend I need them
 
Fuck me
get to the office
contractor causes a power cut
turns out everything was on the same fucking rail, so all this glorious N+1 reliability over 3 rails essentially didn't exist
 
 
1 hour later…
12:05 PM
@SébastienRenauld never trust anything you didn't do yourself :p
 
12:19 PM
Yeah
Could've been fucking disastrous if something that required a master ran on there though
as it happens, everything is masterless so work as normal
 
12:51 PM
"To iterate is human, to recurse divine" - yeah, and to know your language doesn't have optimizations for it is what?
 
I don't like it either. To recurse is student while to iterate is pro
(and let's not lose time over tail call optimization)
 
I was using that as a simple example of why you need to know what you're doing and not some random thing you read on a chinese cookie/blog
 
Your comment might be felt as a little insulting, don't you think ?
 
Rewrote it
 
@DenysSéguret TCO can be straightforward.
 
1:01 PM
> You are right, generally. Walking a tree is a perfectly legitimate application for non-tail-optimized recursion, though.
Thinking face
 
When TCO can really be used and you're competent enough to use it, then recursion doesn't really help you. In most cases, you'll lose time checking whether it applies. That's why I think TCO isn't really worth pursuing.
 
Isn't walking a tree the prime example of TCO
 
What ? I don't think TCO can apply while walking a tree
 
@DenysSéguret Your comment only applies to imperative languages, and even in those languages, sometimes the iterative solution is much more difficult to write than the recursive one
 
The more it goes the less sense this question makes
Think I'm just going to avoid that question. There's a trainwreck or two about to happen and mismatch in requirements (the first answer has a comment essentially going for code readability, the original question itself meanwhile forces recursion)
 
1:06 PM
I think this question is mainly its title (ie "Building an iterator for walking a tree recursively"). The rest is just decoration
 
@SébastienRenauld Looks like your answer is extensive and accepted; is there anythign else I can help with?
 
No, it was before that :-)
now it's all good
I was not entirely sure what would go on the heap and what would not, but a quick test or two solved that issue
 
@SébastienRenauld why shouldn't the question be a dupe of stackoverflow.com/questions/49012277/…
 
Originally, it probably should've. It turned very quickly into a performance question backed by a misunderstanding of C++ internals though
 
1:21 PM
@SébastienRenauld Why haven't you edited the question to reflect this change?
 
Should I have?
 
How would someone looking for this performance discussion find that question (and subsequent answer)
 
I don't touch people's questions, typically, or at least I don't add to them
 
I wouldn't either. I don't like changing a question to make the answer more relevant
 
Ok, I'll do it
Otherwise is is a dupe and I'll mark it as such
You are asserting that it's distinct
 
1:23 PM
The original would've been a dupe, the comments set it apart
 
And you are supposed to move comments into the question / answer post
 
Just a link to the other question would be good enough. There's no hard obligation to reduce the number of questions. When I look for a problem I can read two QA
 
comments should be expected to disappear
The related question is why didn't you vote to close it as a duplicate instead of answering?
@DenysSéguret My main issue is in keeping the answers updated
The vast majority of answerers never go back and fix things
And having duplicate answers makes that process N times harder
Or in this case, clarifying the question to be a "compare C++ to Rust" question makes the answer's details about stuff make more sense.
-1
Q: How do I build an iterator for walking a file tree recursively?

Alexey OrlovI want to lazily consume the nodes of a file tree one by one while sorting the siblings on each level. In Python, I'd use a synchronous generator: def traverse_dst(src_dir, dst_root, dst_step): """ Recursively traverses the source directory and yields a sequence of (src, dst) pairs; ...

Related: don't ever assume that the OP has done a basic search for the answer.
There are other "how do I make recursive iterator" questions
 
 
2 hours later…
3:11 PM
I closed that as dupe, but then realized that OPs question in the title wasn't the question in the body.
I haven't found a slam-dunk existing answer for "why doesn't one line work"
Should it be reopened?
 
3:34 PM
The dupe target was clearly not relevant
But it's certainly a dupe, isn't it ?
I mean we must have QA explaining you can't just have references without owned values
 
@DenysSéguret the "return a string slice" one?; sure it's relevant, why wouldn't it be?
 
Oh, I hadn't even seen this one
Yes it looks relevant
 
Greater point, though, there seems to be so much misconception/so many issues people hit on &str
generally thinking it is a type when the & alone should clearly highlight its real nature
 
Which has the same error message as the version with the correct syntax would have reported.
 
@SébastienRenauld Strings are the first thing you encounter in any language. People try them before they even know about the borrow checker. It's natural to be confused at the beginning (not searching before asking SO is totally a different issue, though).
 
3:45 PM
Don't get me wrong, I'm not blaming them
I'm just trying to think of what could be done to get to this issue sooner
(I'd wager a drink or two that we've all been bitten at some point by this particular thing)
 
A related problem is that people get it into their head that "&str is universally better than String"
 
@Shepmaster It's an easy trap
 
@PeterHall Indeed. We (SO and the broader community) fuel that as well.
The guideline is "use &str except when you shouldn't" ;-)
the long form is a lot harder
 
Today and yesterday I am untangling a mess that is only there because a younger version of me was avoiding heap allocation at all cost
 
@PeterHall Peter from 2 days ago was a wild child, eh?
 
3:54 PM
It might have been only 3 months ago
To be fair on myself, it wasn't crazy, but it led to complex situations and not everything added since then had the luxury of lots of careful design planning. A few heap allocations and I can get rid of a pile of complexity.
 
 
3 hours later…
6:51 PM
> Support async drop
> However, we've decided to largely defer this sort of work until we've finished off more of the polish work on async-await.
 
That domdocument question
I wonder if he wants DOMDocument with the quirks, or without the quirks
 
7:21 PM
@SébastienRenauld they want DOMDocument::do_what_i_want_but_faster
 
Oh, I understood as much
Left a comment to that extent
 
7:46 PM
@Shepmaster I knew it! That feature was missing!
I wonder how they will design that, tho
How that wouldn't conflict with the regular Drop
 
8:43 PM
I'm struck again by how closed hyper's APIs are.
e.g. serve
S: MakeServiceRef, but MakeServiceRef is a private trait
 
 
3 hours later…
11:41 PM
Yup
it is possible to circumvent that but it's honestly not easy
 

« first day (1806 days earlier)      last day (1686 days later) »