3 ms·
I've been experimenting with Rust for a few weeks, and I really like it, but I hope they improve how you write functions that return iterators. I can't find all
by pjungwir 11y ago
I've been experimenting with Rust for a few weeks, and I really like it, but I hope they improve how you write functions that return iterators. I can't find all the discussion now, but here is some of it:
http://stackoverflow.com/questions/27535289/correct-way-to-return-an-iterator http://stackoverflow.com/questions/27535289/correct-way-to-r...
https://www.reddit.com/r/rust/comments/2h26cj/functions_returning_iterators/ https://www.reddit.com/r/rust/comments/2h26cj/functions_retu...
https://github.com/rust-lang/rfcs/pull/105 https://github.com/rust-lang/rfcs/pull/105
https://github.com/rust-lang/rfcs/pull/1305 https://github.com/rust-lang/rfcs/pull/1305
Reading those RFCs can be frustrating, where a discussion goes on for over a year and people add more and more wants to an idea until it sinks. Same thing with the discussion about a `yield` keyword:
https://github.com/rust-lang/rust/issues/7746 https://github.com/rust-lang/rust/issues/7746
https://github.com/rust-lang/rfcs/issues/388 https://github.com/rust-lang/rfcs/issues/388
It reminds me of the JCP in Java. I guess every standards committee is like this, and I actually like how careful the Rust team is about extending the language---but I think we should be prepared for it to evolve slowly. Right now I feel like Rust's pace will be more like Java than C#.
- steveklabnik 11y agoOne reason you're seeing slowness is that the compiler is undergoing an internal refactoring that will _completely change_ the way these kinds of features will be implemented. So they're effectively on-hold-ish until after that's done. Also, this particular feature seems easy from a usage perspective, but the type theory behind it is actually pretty intense, and there's multiple possible ways of doing it. So those need to be explored, discussed, and figured out. This feature is one that's of high importance, and is coming sooner rather than later.
- pjungwir 11y agoThanks for the reassurance! Sorry if I sound critical. There will always be a tradeoff between speed and purity---Java vs C# is a actually a pretty interesting case study---and for a language that is as experimental as Rust, I think taking your time to make careful decisions is the right approach. I'm just trying to prepare myself for the wait. :-) Also thanks to you personally for your work making Rust accessible to us newbies. The book is very nice, and a few weeks ago you were really quick to answer a question of mine on IRC. Keep up the good work!
- steveklabnik 11y agoNo bad feels taken! You're welcome. I hope the next iteration of the book is even better :)
- runiq 11y agoDo you have a link to an RFC for that, by any chance? Thanks for the book, by the way! It's an awesome resource. :)
- steveklabnik 11y agoHere's a summary: https://news.ycombinator.com/item?id=10713301 https://news.ycombinator.com/item?id=10713301 Here are the two RFCs: https://github.com/rust-lang/rfcs/blob/master/text/1191-hir.md https://github.com/rust-lang/rfcs/blob/master/text/1191-hir.... https://github.com/rust-lang/rfcs/blob/master/text/1211-mir.md https://github.com/rust-lang/rfcs/blob/master/text/1211-mir.... And thanks! I'm hoping the second draft will be even better.
- fanf2 11y agoAre you using the term "desugaring" to describe the AST to HIR translation? Or do you have different jargon?
- Manishearth 11y agoNote that you can just return `Box<Iterator<Item=...>>`. Slight allocation+virtual dispatch overhead there, but not much. Note that there is good activity around abstract return types happening (seems to be something the core team is putting effort into?), so it might happen soon.