Re: [rust-dev] Porting some nesC features to rust?

2014-04-02 Thread Ashish Myles
And just in case there is a confusion (as I have noticed others to have), it might help to see a specific example comparing static dispatch with dynamic. // This is a single function for all types implementing the LCD Trait. fn foo(x : LCD) { // x's type is LCD rather than the actual type of the

Re: [rust-dev] Possible bug? os::args() then split then print

2014-02-25 Thread Ashish Myles
On Tue, Feb 25, 2014 at 11:00 AM, Phil Dawes rustp...@phildawes.net wrote: fn main() { let arr : ~[str] = std::os::args()[1].split_str(::).collect(); std::io::println(first + arr[0]); std::io::println(first again + arr[0]); } I am working on an older version of the compiler

Re: [rust-dev] How to use dynamic polymorphism with collection

2014-02-08 Thread Ashish Myles
On Sat, Feb 8, 2014 at 6:48 PM, Ashish Myles marci...@gmail.com wrote: On Sat, Feb 8, 2014 at 1:21 PM, Philippe Delrieu philippe.delr...@free.fr wrote: pub trait Base { fn do_base(self); } struct TestBase; impl Base for TestBase{ fn do_base(self){ println

Re: [rust-dev] Converting ~[T] embedded in struct to [T]

2014-01-19 Thread Ashish Myles
Thanks for the detailed explanations! On Sun, Jan 19, 2014 at 2:01 AM, Alex Crichton a...@crichton.co wrote: fn borrow1'a('a self) - 'a int { match (self) { // error: mismatched types: expected `'a int` but found `~int` // (expected -ptr but found

Re: [rust-dev] Cloning a statically-sized array

2014-01-19 Thread Ashish Myles
straightened out. On Sun, Jan 19, 2014 at 12:19 AM, Daniel Micay danielmi...@gmail.comwrote: On Sun, Jan 19, 2014 at 12:17 AM, Ashish Myles marci...@gmail.com wrote: Now, I already know that statically-sized arrays of primitives are implicitly copyable, but consider, for example, a statically

Re: [rust-dev] Converting ~[T] embedded in struct to [T]

2014-01-19 Thread Ashish Myles
Thanks! I appreciate the detailed answers and look forward to future changes. :) And I had already run into and started reading Niko's article you linked for DSTs. I love the thorough analyses you guys go through for each feature. Ashish On Sun, Jan 19, 2014 at 1:17 PM, Alex Crichton

[rust-dev] Converting ~[T] embedded in struct to [T]

2014-01-18 Thread Ashish Myles
I understand as per a previous discussion that the owned box ~[T] doesn't quite have the semantics of a unique *pointer*. Below include my successes in some borrowing scenarios and analogous failed attempts at borrowing a reference to a unique pointer to an array within a FooVec struct. How do I

[rust-dev] Cloning a statically-sized array

2014-01-18 Thread Ashish Myles
Now, I already know that statically-sized arrays of primitives are implicitly copyable, but consider, for example, a statically-sized array of a non-copyable but Clone-able type. I find that for v of type [T, ..2], v.clone() is not a static array. Perhaps it's because v is being implicitly

[rust-dev] Macros expanding to multiple statements

2014-01-11 Thread Ashish Myles
Rust 0.9 indicates that support for expansion of macros into multiple statements is now supported, and the following example from the test suite works for me. https://github.com/mozilla/rust/blob/master/src/test/run-pass/macro-multiple-items.rs However, I receive an error for the following code

Re: [rust-dev] Macros expanding to multiple statements

2014-01-11 Thread Ashish Myles
macros are covered by https://github.com/mozilla/rust/issues/10681 . Huon On 12/01/14 13:40, Ashish Myles wrote: Rust 0.9 indicates that support for expansion of macros into multiple statements is now supported, and the following example from the test suite works for me. https

[rust-dev] What type to put for index when impl-ing Index?

2014-01-08 Thread Ashish Myles
The following implementation of Index for Foo works fine. struct Foo([f64, ..3]); impl Indexuint, f64 for Foo { fn index(self, index: uint) - f64 { match self { Foo(ref v) = v[*index].clone() } } } fn main() { let tmp : uint = 0; let foo = Foo([1.0,

Re: [rust-dev] What type to put for index when impl-ing Index?

2014-01-08 Thread Ashish Myles
!({:?}, foo[tmp]); } On 9 Jan 2014, at 2:08 pm, Ashish Myles marci...@gmail.com wrote: The following implementation of Index for Foo works fine. struct Foo([f64, ..3]); impl Indexuint, f64 for Foo { fn index(self, index: uint) - f64 { match self { Foo(ref v) = v

Re: [rust-dev] Auto-borrow/deref (again, sorry)

2013-12-28 Thread Ashish Myles
I think I see the confusion (as I suffered from the same point of confusion). So let me restate your answer and please correct me of I am wrong. 1. mut int and mut int are different types and the former doesn't automatically convert to the latter. 2. The way to get the latter from the former is

[rust-dev] Define copyable types for [T, ..2] static vector initialization

2013-11-29 Thread Ashish Myles
Previously we had the Copy trait, which when implemented by trait T allowed one to write [Zero::zero(), ..SZ] where T implemented the Zero trait. But now I am not sure how to get that behavior. Concretely, here is the code I want to get compiling. (Just to check, I added both Clone and

Re: [rust-dev] Define copyable types for [T, ..2] static vector initialization

2013-11-29 Thread Ashish Myles
? On Nov 29, 2013 6:47 PM, Huon Wilson dbau...@gmail.com wrote: On 30/11/13 10:33, Ashish Myles wrote: Previously we had the Copy trait, which when implemented by trait T allowed one to write [Zero::zero(), ..SZ] where T implemented the Zero trait. But now I am not sure how to get

Re: [rust-dev] Define copyable types for [T, ..2] static vector initialization

2013-11-29 Thread Ashish Myles
in range(0u, SZ as uint) { intrinsics::move_val_init(mut ary[i], Zero::zero()); } } Foo(ary) } } -Kevin On Nov 29, 2013, at 7:05 PM, Ashish Myles marci...@gmail.com wrote: Is there a plan to support fix-sized vector initialization without

Re: [rust-dev] Define copyable types for [T, ..2] static vector initialization

2013-11-29 Thread Ashish Myles
On Nov 29, 2013, at 8:37 PM, Ashish Myles marci...@gmail.com wrote: That's some seriously nifty stuff, which got my stuff compiling again. :) But for the long term, it would be nice to have a syntax that behaves as was the case with the Copy trait -- it takes a single value and clones

Re: [rust-dev] deriving Clone on a struct with a static vector

2013-07-06 Thread Ashish Myles
On Sat, Jul 6, 2013 at 1:43 AM, Patrick Walton pwal...@mozilla.com wrote: On 7/5/13 10:42 PM, Ashish Myles wrote: And an additional question. 3. What is the rationale in having both Copy and Clone? Can one provide an exhaustive list for where one would want to use Copy instead of Clone

Re: [rust-dev] deriving Clone on a struct with a static vector

2013-07-06 Thread Ashish Myles
On Sat, Jul 6, 2013 at 5:45 AM, Jason Fager jfa...@gmail.com wrote: I've started implementing traits for fixed-length vectors with a few macros: https://gist.github.com/jfager/5936197 I don't have Clone yet, but it should be easy to add. As a side note, looking through your code, this is

[rust-dev] Why separate equivalent impls for 'self [A], ~[A], @[A]

2013-07-06 Thread Ashish Myles
Perhaps this was an oversight as the code base has developed organically. But in case it was intentional, I just wanted to check. libstd/to_str.rs defines each of the following impls impl'self,A:ToStr ToStr for 'self [A] implA:ToStr ToStr for ~[A] implA:ToStr ToStr for @[A] whereas

[rust-dev] deriving Clone on a struct with a static vector

2013-07-05 Thread Ashish Myles
1. The following code #[deriving(Clone)] struct V { v : [f64, ..3] } fn main() { } gives the following error tmp.rs:1:11: 1:16 error: mismatched types: expected `[f64, .. 3]` but found `[f64, .. 3]` (expected vector but found -ptr) tmp.rs:1 #[deriving(Clone)] Is this

Re: [rust-dev] deriving Clone on a struct with a static vector

2013-07-05 Thread Ashish Myles
And an additional question. 3. What is the rationale in having both Copy and Clone? Can one provide an exhaustive list for where one would want to use Copy instead of Clone/DeepClone? I tried to use clone everywhere, but I needed T : Copy + Zero to be able to write, for example, [Zero::zero(),..

Re: [rust-dev] Rust 0.7 prerelease testing

2013-07-03 Thread Ashish Myles
openSUSE 12.2 (i.e. previous release). make check succeeds: summary of 25 test runs: 5261 passed; 0 failed; 302 ignored ___ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev

Re: [rust-dev] Rust 0.7 prerelease testing

2013-07-03 Thread Ashish Myles
On Wed, Jul 3, 2013 at 4:00 PM, Ashish Myles marci...@gmail.com wrote: openSUSE 12.2 (i.e. previous release). make check succeeds: summary of 25 test runs: 5261 passed; 0 failed; 302 ignored To clarify, I did the check against trunk (0c6fc46c030ab0515a052fa99c9e10c75cfc8184), and my

[rust-dev] Borrow lifetime assignment changed?

2013-07-03 Thread Ashish Myles
Any idea why the following fails use std::{io,rand,task}; fn main() { for [Alice, Bob, Carol].iter().advance |name| { do task::spawn { use std::rand::RngUtil; let v = rand::rng().shuffle([1, 2, 3]); for v.iter().advance |num| {

Re: [rust-dev] Front page example

2013-06-23 Thread Ashish Myles
Great, thanks, it works! Is there a way to invoke the shuffle() without bringing it explicitly into local scope, say via some verbose way that specifies the trait to be used? Ashish On Sat, Jun 22, 2013 at 11:00 PM, Huon Wilson dbau...@gmail.com wrote: On 23/06/13 12:53, Ashish Myles wrote

[rust-dev] tjc's pre-talk and talk (was: This Week in Rust)

2013-06-22 Thread Ashish Myles
- tjc's pre-talk and talk, Rust: A Friendly Introduction went very well. The [slides](http://catamorphism.org/Writing/Rust-Tutorial-tjc.pdf) are up, and a recording is coming soon (hopefuly). tjc says the slides aren't as understanable without the audio of the talk. Thanks for the

[rust-dev] Front page example

2013-06-22 Thread Ashish Myles
I have been out of rust for a bit, and coming back to it, I am having a difficult time adapting the front page example at http://www.rust-lang.org/ to the trunk version of rust (updated last night). I turned the example to use std::*; fn main() { for [Alice, Bob, Carol].each |name|

[rust-dev] Macro bugs or misunderstanding of use?

2013-04-09 Thread Ashish Myles
Hi, I am running the rust compiler from trunk. My macro usage seems to be a macro_rules! my_print( ($a:expr, $b:expr) = ( io::println(fmt!(%d, a)); io::println(fmt!(%d, b)); ); ) fn main() { let a : int = 1; let b : int = 2; my_print!(a, b); }

[rust-dev] How to use concat_idents! properly

2013-03-02 Thread Ashish Myles
So far, I have had a difficult time finding anything definitive on this except for some rust test code. fn main() { // PART 1: works (from rust test code) let asdf_fdsa = ~.; io::println(concat_idents!(asd, f_f, dsa)); io::println(stringify!(use_mention_distinction)); // PART

Re: [rust-dev] How to use concat_idents! properly

2013-03-02 Thread Ashish Myles
On Sat, Mar 2, 2013 at 1:41 PM, Paul Stansifer paul.stansi...@gmail.com wrote: `concat_idents!` is currently broken, and it's my fault. Here's a discussion of how it might be fixed in the future: https://mail.mozilla.org/pipermail/rust-dev/2013-February/003170.html Sadly, there is no

Re: [rust-dev] I wanted a dollar but you gave me a ... dollar?

2013-02-24 Thread Ashish Myles
On Sun, Feb 24, 2013 at 12:06 AM, Ashish Myles marci...@gmail.com wrote: On Fri, Feb 22, 2013 at 12:35 PM, John Clements cleme...@brinckerhoff.org wrote: On Feb 22, 2013, at 6:22 AM, Paul Stansifer wrote: Rust syntax expects a literal number in the `[T * n]` construct; from the parser's

Re: [rust-dev] I wanted a dollar but you gave me a ... dollar?

2013-02-23 Thread Ashish Myles
On Fri, Feb 22, 2013 at 12:35 PM, John Clements cleme...@brinckerhoff.org wrote: On Feb 22, 2013, at 6:22 AM, Paul Stansifer wrote: Rust syntax expects a literal number in the `[T * n]` construct; from the parser's point of view, what it receives is an expression, without any

[rust-dev] Simple use of templates/generics compilation hassles

2013-02-21 Thread Ashish Myles
Well, I eventually figured out how to get things compiling, but it was highly non-obvious. I would appreciate it if someone could shed some light on why things behave this way so that I may learn to visually see the error. Say we have the following struct pub struct Vector3T { priv

[rust-dev] Cloning managed memory between tasks?

2013-02-20 Thread Ashish Myles
I didn't much previous discussion on this topic on google. Sorry if I missed something and re-starting an old discussion. Here is an example from the manual of a standard lisp-style list. enum ListT { Nil, Cons(T, @ListT) } If one wished to move such a list to another task, a copy to

[rust-dev] Many little questions while writing a Vector class

2013-02-20 Thread Ashish Myles
Lots of questions. 1. Is there an array string join function? I looked through possible pertinent vector- and string-related modules and I didn't see something equivalent. 2. Any particular reason to_str() for arrays (defined in in std::to_str) is defined only for unique arrays?

[rust-dev] Parametrizing traits by integers (or equivalent behavior)

2013-02-18 Thread Ashish Myles
Firstly, as this seems to be the only discussion mailing list for rust, I presumed that this might be a good place to ask newbie-ish questions. Please correct me if I am wrong. (I have previously played around with D, which has separate mailing lists for learners.) I am particularly interested in