Re: [rust-dev] Checking error at opening file

2013-11-03 Thread John Mija
Hi Alex, I had seen an example at http://static.rust-lang.org/doc/master/std/rt/io/file/fn.open.html which closes the file at the end of a block. I simply wants to open a file, checking if there is any error, for later to can read it line by line until the end of file. I was wrong using the

Re: [rust-dev] Checking error at opening file

2013-11-03 Thread Diggory Hardy
Well, your program needs to handle the error somehow if there is one. Something like this could work (though syntax may be wrong): let file = match io::result(|| File::open(&Path::new("/some/path")) { Ok(f) => f /* i.e. file is set to f */ Err(e) => fail!("cannot open file") } Alternativ

Re: [rust-dev] Checking error at opening file

2013-11-03 Thread Ziad Hatahet
Out of curiosity, why not make File::open() return a Result<> instead of Option<> like it does now? The current implementation already seems to be matching against the result of fs_open() and returning None if the result is Err(). So why the extra level of indirection and raising a condition in tha

Re: [rust-dev] Checking error at opening file

2013-11-03 Thread Alex Crichton
> Out of curiosity, why not make File::open() return a Result<> instead of > Option<> like it does now? This is a relic of I/O using conditions. The idea here is that if you wanted to catch the condition, you can indeed catch it (and do something appropriate). If you don't catch it then the task f

[rust-dev] Separating heaps from tasks

2013-11-03 Thread Oren Ben-Kiki
I am toying with a non-trivial Rust project to get a feel for the language. There's a pattern I keep seeing in my code which isn't easy to express in Rust. I wonder what the "right thing to do" is here. The pattern is as follows. I have some container, which contains some components of different t

Re: [rust-dev] Separating heaps from tasks

2013-11-03 Thread Patrick Walton
On 11/3/13 10:11 PM, Oren Ben-Kiki wrote: At any rate - is this something that makes sense in the Rust view? If so, is there a chance of something like that being added (a completely separate question :-)? Two questions: (1) In your proposal, do the cross-thread GC pointers have mutable conte

Re: [rust-dev] Separating heaps from tasks

2013-11-03 Thread Daniel Micay
On Mon, Nov 4, 2013 at 1:11 AM, Oren Ben-Kiki wrote: > I am toying with a non-trivial Rust project to get a feel for the > language. There's a pattern I keep seeing in my code which isn't easy to > express in Rust. I wonder what the "right thing to do" is here. > > The pattern is as follows. I ha

Re: [rust-dev] Separating heaps from tasks

2013-11-03 Thread Oren Ben-Kiki
On Mon, Nov 4, 2013 at 8:13 AM, Patrick Walton wrote: > On 11/3/13 10:11 PM, Oren Ben-Kiki wrote: > >> At any rate - is this something that makes sense in the Rust view? >> If so, is there a chance of something like that being added (a >> completely separate question :-)? >> > > Two questions: >

Re: [rust-dev] Separating heaps from tasks

2013-11-03 Thread Patrick Walton
On 11/3/13 10:19 PM, Oren Ben-Kiki wrote: Because they don't allow cycles. Aha. I personally think we should relax this restriction; it's pretty onerous. Patrick ___ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust

Re: [rust-dev] Separating heaps from tasks

2013-11-03 Thread Oren Ben-Kiki
Yes, using keys (or indices into a vector) is an option. There are two problems with this. It is pretty inefficient; one has to access the pool at any point, which means doubling the sizes of the pointers (at least), probably more; One needs a lot of unsafe code to allow mutating the pools; And th

Re: [rust-dev] Separating heaps from tasks

2013-11-03 Thread Oren Ben-Kiki
Even if RC allowed cycles (I don't quite see how...) the whole thing wouldn't be send-able, unless one uses ARC. But ARC has even more performance penalties than RC... And doing cycle-supporting ARC across tasks seems like pushing it - you might as well admit you are doing global GC in the 1st plac

Re: [rust-dev] Separating heaps from tasks

2013-11-03 Thread Patrick Walton
On 11/3/13 10:29 PM, Oren Ben-Kiki wrote: Even if RC allowed cycles (I don't quite see how...) the whole thing wouldn't be send-able, unless one uses ARC. But ARC has even more performance penalties than RC... And doing cycle-supporting ARC across tasks seems like pushing it - you might as well a

Re: [rust-dev] Separating heaps from tasks

2013-11-03 Thread Daniel Micay
On Mon, Nov 4, 2013 at 1:29 AM, Oren Ben-Kiki wrote: > Even if RC allowed cycles (I don't quite see how...) the whole thing > wouldn't be send-able, unless one uses ARC. But ARC has even more > performance penalties than RC... And doing cycle-supporting ARC across > tasks seems like pushing it -

[rust-dev] Using libextra within libstd?

2013-11-03 Thread Martin DeMello
I've been looking at https://github.com/mozilla/rust/issues/6085 which seems like it should be fairly simple to fix, however, the proposed solution involves EnumSet from libextra. Is it possible to use stuff from libextra within libstd? It seems to me that it would set up a circular dependency, th

Re: [rust-dev] Using libextra within libstd?

2013-11-03 Thread Daniel Micay
On Mon, Nov 4, 2013 at 2:10 AM, Martin DeMello wrote: > I've been looking at https://github.com/mozilla/rust/issues/6085 which > seems like it should be fairly simple to fix, however, the proposed > solution involves EnumSet from libextra. > > Is it possible to use stuff from libextra within libst