Re: [rust-dev] return type of closure

2013-10-27 Thread Jesse Ruderman
If you don't mind changing ntimes to not return a closure: fn ntimes(f: &fn(T) -> T, times: uint, x: T) -> T { match times { 0u => x, _ => ntimes(|x| f(x), times - 1u, f(x)) } } fn main() { println(format!("{:d}", ntimes(|k| k*2, 2u, 3))); } __

Re: [rust-dev] return type of closure

2013-10-27 Thread Jesse Ruderman
On Sun, Oct 27, 2013 at 9:41 AM, Patrick Walton wrote: > But > by the time the closure is invoked, `f` won't exist, because the activation > record for the `ntimes` function won't exist anymore. I tried tying the lifetime of `f` to the lifetime of the returned function by making them both &'a...,

rust-dev@mozilla.org

2013-09-19 Thread Jesse Ruderman
The example on https://github.com/mozilla/rust/wiki/Meeting-weekly-2013-09-10#fate-of-const seems sensible at first, but the rule it suggests would not be safe. Allowing one closure to take &mut while another takes &const would create a data race if the two closures are executed in parallel. task

[rust-dev] Purity by default

2012-10-23 Thread Jesse Ruderman
Should functions default to pure? * With http://smallcultfollowing.com/babysteps/blog/2012/10/12/extending-the-definition-of-purity-in-rust/ I think most functions will be able to be pure. * Would avoid the problem of forgetting to mark a function as pure, causing pain for a caller. (Or worse,

Re: [rust-dev] A plea for removing context-free ambiguity / context-required parsing

2012-08-25 Thread Jesse Ruderman
A warning for unused pattern bindings would help: https://github.com/mozilla/rust/issues/941 ___ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev

Re: [rust-dev] strings, slices and nulls

2012-04-19 Thread Jesse Ruderman
My preference is to remove null termination: * I'm guessing most strings aren't passed to C. (What are the most common C string calls in rustc?) * C functions that scan for null are inefficient, so they're even more likely to be replaced with Rust equivalents than other C functions. * Null termi

[rust-dev] "pure once it stops failing"

2011-09-24 Thread Jesse Ruderman
I marked interner::get as "pure" on the basis that once it succeeds, it always succeeds and always returns the same thing. I hope this is reasonable. The key typestate guarantee still holds: once you've checked it, you can rely on it. But you can't hoist the check arbitrarily far like you can with

Re: [rust-dev] Are tail calls dispensable?

2011-08-10 Thread Jesse Ruderman
> Agreed it's hard to replicate. What I'm getting at is that at present, it > seems they're rather hard to *support* everywhere, period. How useful are > tail calls if they only work in "very restricted" circumstances? It's a bit > of an offense against language orthogonality and compositionality,