[rust-dev] Autiincrement values in loops

2013-02-01 Thread Alexander Stavonin
Have we a pretty looks solution for auto incrementation counters during loops? I mean something like C/C++ style for loop.I found an example in the manual 10.5 For loops but it looks ugly with counter outside the loop. Is it only way for solving problem? Thanks.

Re: [rust-dev] Autiincrement values in loops

2013-02-01 Thread Josh Matthews
The int/uint::range methods would seem to do the job: for uint::range(0, 10) |i| { io::println(fmt!(%u, i)); } Cheers, Josh On 1 February 2013 12:14, Alexander Stavonin a.stavo...@gmail.com wrote: Have we a pretty looks solution for auto incrementation counters during loops? I mean something

Re: [rust-dev] Autiincrement values in loops

2013-02-01 Thread Josh Matthews
Actually my first suggestion won't work except in trivial circumstances (ie. starting from zero). Sorry. On 1 February 2013 12:32, Josh Matthews j...@joshmatthews.net wrote: Well, constant increments of N can be simulated with |let i = i * N;| in the body of the loop. There's an issue open

Re: [rust-dev] Autiincrement values in loops

2013-02-01 Thread Simon Sapin
Le 01/02/2013 13:28, Alexander Stavonin a écrit : Thanks, it better than nothing, but… It works only for i++; how can I write /i += 2 /or /i--/? The range() function is very simple: https://github.com/mozilla/rust/blob/release-0.5/src/libcore/int-template.rs#L48 #[inline(always)] /// Iterate

Re: [rust-dev] Autiincrement values in loops

2013-02-01 Thread Lucian Branescu
It's also possible to write something like python's enumerate, to get: for enumerate(some_vector) Ii, e| { ... } In general, rust loops are closer to Python's and functional map than C++'s looping constructs. On 1 February 2013 12:37, Simon Sapin simon.sa...@exyr.org wrote: Le 01/02/2013

Re: [rust-dev] Autiincrement values in loops

2013-02-01 Thread Alexander Stavonin
I guess, the solution will not work for -1 … -10 On Feb 1, 2013, at 9:37 PM, Simon Sapin simon.sa...@exyr.org wrote: Le 01/02/2013 13:28, Alexander Stavonin a écrit : Thanks, it better than nothing, but… It works only for i++; how can I write /i += 2 /or /i--/? The range() function is very

Re: [rust-dev] Autiincrement values in loops

2013-02-01 Thread Simon Sapin
Le 01/02/2013 13:38, Lucian Branescu a écrit : It's also possible to write something like python's enumerate, to get: for enumerate(some_vector) Ii, e| { ... } In general, rust loops are closer to Python's and functional map than C++'s looping constructs. Python’s enumerate() works on any

Re: [rust-dev] Autiincrement values in loops

2013-02-01 Thread Benjamin Striegel
There's already a function to do this: fn main() { for int::range_step(0, 10, 2) |i| { log(error, i); } for int::range_step(10, 0, -1) |i| { log(error, i); } } On Fri, Feb 1, 2013 at 7:28 AM, Alexander Stavonin

Re: [rust-dev] Autiincrement values in loops

2013-02-01 Thread Benjamin Striegel
Though note that this function is relatively new, you'll need to be on a recent unstable version rather than 0.5. On Fri, Feb 1, 2013 at 8:48 AM, Benjamin Striegel ben.strie...@gmail.comwrote: There's already a function to do this: fn main() { for int::range_step(0, 10, 2) |i| {

Re: [rust-dev] trait and lifetime

2013-02-01 Thread Niko Matsakis
What you want is something like this (and corresponding changes to the impl): pub trait TupleValT { pub pure fn _1(self) - self/T; pub pure fn _2(self) - self/T; } The `self` declaration is called an explicit self declaration. What you have currently written is called implicit self

[rust-dev] Rust 0.5 for Windows

2013-02-01 Thread Bruce M. Axtens
I'm having problems with the installer for 0.5 on Windows. I end up with folders containing a mix of normal length files and zero length files. When I try to run rustc.exe I get a dialog about some libgcc*.dll not being present Any clues? Kind regards, Bruce.

Re: [rust-dev] Misc questions

2013-02-01 Thread Michael Neumann
Am 30.01.2013 00:43, schrieb Brian Anderson: On 01/29/2013 04:47 AM, Michael Neumann wrote: Am 29.01.2013 03:01, schrieb Brian Anderson: On 01/28/2013 05:29 PM, Graydon Hoare wrote: On 13-01-28 04:56 PM, Brian Anderson wrote: I think libuv is doing too much here. For example, if I don't

Re: [rust-dev] Autiincrement values in loops

2013-02-01 Thread Simon Sapin
Le 01/02/2013 14:50, Benjamin Striegel a écrit : Though note that this function is relatively new, you'll need to be on a recent unstable version rather than 0.5. Is it a bug that it’s not documented? http://static.rust-lang.org/doc/core/int.html -- Simon Sapin

Re: [rust-dev] Rust 0.5 for Windows

2013-02-01 Thread Graydon Hoare
On 13-02-01 06:39 AM, Bruce M. Axtens wrote: I'm having problems with the installer for 0.5 on Windows. I end up with folders containing a mix of normal length files and zero length files. When I try to run rustc.exe I get a dialog about some libgcc*.dll not being present The 0-length files

Re: [rust-dev] Rust 0.5 for Windows

2013-02-01 Thread Tim Chevalier
On Fri, Feb 1, 2013 at 10:13 AM, Graydon Hoare gray...@mozilla.com wrote: On 13-02-01 06:39 AM, Bruce M. Axtens wrote: I'm having problems with the installer for 0.5 on Windows. I end up with folders containing a mix of normal length files and zero length files. When I try to run rustc.exe I

Re: [rust-dev] Rust 0.5 for Windows

2013-02-01 Thread Felix S Klock II
On Fri Feb 1 19:13:03 2013, Graydon Hoare wrote: (they act as sequence-points for make, since it cannot easily guess the actual hash-based output filenames of the libraries) I was idly wondering about those hashy filenames: Is the long term plan to continue to encoding hashes into the

[rust-dev] Container framework?

2013-02-01 Thread Chris Peterson
strcat and I have been casually brainstorming about container traits. Has there been previous discussion about standardizing a container trait hierarchy and method naming convention? Below is a rough sketch of a simple container framework, inspired by Scala, Python, and C++ STL. Scala has a

Re: [rust-dev] Rust 0.5 for Windows

2013-02-01 Thread Graydon Hoare
On 13-02-01 10:21 AM, Felix S Klock II wrote: On Fri Feb 1 19:13:03 2013, Graydon Hoare wrote: (they act as sequence-points for make, since it cannot easily guess the actual hash-based output filenames of the libraries) I was idly wondering about those hashy filenames: Is the long term plan

Re: [rust-dev] Container framework?

2013-02-01 Thread Graydon Hoare
On 13-02-01 10:36 AM, Chris Peterson wrote: strcat and I have been casually brainstorming about container traits. Has there been previous discussion about standardizing a container trait hierarchy and method naming convention? Not much; what we've had was encoded mostly in the core::iter and

Re: [rust-dev] Container framework?

2013-02-01 Thread Erick Tryzelaar
FYI, I'm in the process of converting fun_treemap into an AA Tree and implement much of the container traits. In the process, I've extracted out the mutation functions from Map and Set into their own Mutable{Map,Set} trait, and added Immutable{Map,Set} traits for persistent types. So please talk

Re: [rust-dev] Container framework?

2013-02-01 Thread Chris Peterson
On 2/1/13 11:24 AM, Graydon Hoare wrote: - I think the double-ended circular vec struct (implemented unsafely) should probably be called Buf. It's the replacement for DVec. Alternatively call it Queue and come up with another name for the can access at either end trait. Deque

Re: [rust-dev] Container framework?

2013-02-01 Thread Chris Peterson
On 2/1/13 11:48 AM, Erick Tryzelaar wrote: FYI, I'm in the process of converting fun_treemap into an AA Tree and implement much of the container traits. In the process, I've extracted out the mutation functions from Map and Set into their own Mutable{Map,Set} trait, and added

Re: [rust-dev] Container framework?

2013-02-01 Thread Erick Tryzelaar
On Friday, February 1, 2013, Chris Peterson wrote: Is it necessary to differentiate Mutable- and Immutable- container traits when mutating methods would take `mut self` and read-only accessors take `self`? Well, we need the MutableMap-style traits, but we could fold the ImmutableMap-style

Re: [rust-dev] idea for Rust playground - seeking comments

2013-02-01 Thread Marijn Haverbeke
See also http://codemirror.net/mode/rust/ . Unfortunately, the syntax has changed massively since I wrote that highlighting mode. On the bright side, I believe the syntax became somewhat more regular, so (though I'm not sure about this) a lot of the complexity in the highlighter (and believe me,

[rust-dev] Compilation Error in Rust in Nesting of Modules

2013-02-01 Thread Ranvijay Singh
Hi, I am getting compilation error while implementing the nesting of modules as per the Rust Language tutorial. Below is the description of my code structure. Inside example directory,I created a file orig.rs and declared 3 modules a, b and c inside it. Inside module c, I declared another module

Re: [rust-dev] idea for Rust playground - seeking comments

2013-02-01 Thread pablo fernandez
Is that the same syntax highlighter that github uses for their gists? Pablo On Fri, Feb 1, 2013 at 7:02 PM, Marijn Haverbeke mari...@gmail.com wrote: See also http://codemirror.net/mode/rust/ . Unfortunately, the syntax has changed massively since I wrote that highlighting mode. On the

Re: [rust-dev] RFC: Explicit stack switching

2013-02-01 Thread Brian Anderson
On 02/01/2013 09:23 AM, Matthieu Monrocq wrote: On Fri, Feb 1, 2013 at 12:09 PM, Michael Neumann mneum...@ntecs.de mailto:mneum...@ntecs.de wrote: Am 31.01.2013 23:37, schrieb Patrick Walton: Hi everyone, With the revamp of the scheduler underway, I'd like to propose

Re: [rust-dev] trait and lifetime

2013-02-01 Thread Alexander Stavonin
Thank you! But I still can not compile it: 1 pub trait TupleValT { 2 pub pure fn _1(self) - self/T; 3 pub pure fn _2(self) - self/T; 4 } 5 6 impl T(T, T): TupleValT { 7 pure fn _1(self) - self/T { 8 let (a, _) = self;

Re: [rust-dev] trait and lifetime

2013-02-01 Thread Niko Matsakis
You need let (a, _) = *self or let (a, _) = self. self is a pointer to a tuple, not a tuple. Niko Alexander Stavonin wrote: Thank you! But I still can not compile it: 1 pub trait TupleValT { 2 pub pure fn _1(self) - self/T; 3 pub pure fn _2(self) - self/T; 4 } 5

Re: [rust-dev] trait and lifetime

2013-02-01 Thread Alexander Stavonin
Thank you very much! I guess had better extend your Borrowed pointers tutorial with information about traits. At least for me it's unclear from the tutorial. On Feb 2, 2013, at 9:08 AM, Niko Matsakis n...@alum.mit.edu wrote: You need let (a, _) = *self or let (a, _) = self. self is a pointer

Re: [rust-dev] trait and lifetime

2013-02-01 Thread Alexander Stavonin
I made changes as you told me: 1 pub trait TupleValT { 2 pub pure fn _1(self) - self/T; 3 /*pub pure fn _2(self) - self/T;*/ 4 } 5 6 impl

Re: [rust-dev] idea for Rust playground - seeking comments

2013-02-01 Thread Benjamin Striegel
Is that the same syntax highlighter that github uses for their gists? No, Github uses Pygments for their syntax highlighting. And though there exists a Rust highlighter in Pygments, it's a newer version of Pygments that Github's Ruby-based Pygments wrapper doesn't yet support. Though note that

Re: [rust-dev] trait and lifetime

2013-02-01 Thread Niko Matsakis
Sorry, I told you wrong. When you write: let (a, _) = self; a You are actually copying the value out of `self` and into the stack variable `a`. The error message is telling you that you are returning a pointer into your stack frame, which is of course unsafe. What you actually want is

Re: [rust-dev] RFC: Explicit stack switching

2013-02-01 Thread Brian Anderson
On 02/01/2013 03:14 PM, Brian Anderson wrote: On 02/01/2013 09:23 AM, Matthieu Monrocq wrote: On Fri, Feb 1, 2013 at 12:09 PM, Michael Neumann mneum...@ntecs.de mailto:mneum...@ntecs.de wrote: Am 31.01.2013 23:37, schrieb Patrick Walton: Hi everyone, With the revamp

Re: [rust-dev] RFC: Explicit stack switching

2013-02-01 Thread Brian Anderson
On 02/01/2013 11:02 PM, Brian Anderson wrote: On 02/01/2013 03:14 PM, Brian Anderson wrote: On 02/01/2013 09:23 AM, Matthieu Monrocq wrote: do reserve_stack(Standard) { rust_task_fail(); } Of course that's do reserve_stack(Standard) { unsafe { rust_task_fail(); } }