Re: [rust-dev] Using char literals with non-char match

2012-10-22 Thread Graydon Hoare
On 22/10/2012 6:52 AM, Henri Sivonen wrote: I can make the translator generate integer literals as the patterns for the arms of the match. However, I think the generated Rust code would be nicer for humans to read with char literals in the patterns. Write it like: match c as char { ... }

[rust-dev] Borrowed pointers

2012-10-22 Thread Vadim
After reading the Borrowed Pointer Tutorial, I started wondering: why should the programmer have to specify whether to pass function parameters by-copy of by-reference? Couldn't Rust just drop the '' sigil and let the compiler decide on parameter passing mode? If functions parameters are

[rust-dev] Transpiling to Rust

2012-10-22 Thread Chad Retz
I am very new to Rust, but I have a little project where I'd like to compile something else into Rust code. I have seen the macro syntax which doesn't operate on pure strings (from what I see) and I have seen projects like rust-repl that parse and inject at runtime. Which approach should I take if

[rust-dev] Warn on useless comparisons

2012-10-22 Thread Viktor Dahl
I believe that the addition of warnings for useless comparisons, similar to gcc's -Wtype-limits would be a nice feature to have for a safety-minded language such as Rust. Consider this program: fn main() { let x = ~[1, 2, 3, 4, 5]; let mut i = x.len() - 1; while i = 0 {

Re: [rust-dev] Using char literals with non-char match

2012-10-22 Thread Nathan
On Mon, Oct 22, 2012 at 10:05 AM, Patrick Walton pwal...@mozilla.com wrote: On 10/22/12 9:08 AM, Graydon Hoare wrote: I suggest allowing char literals when matching on an integer (or when otherwise comparing to an integer or when assigning to an integer variable) as long as the Unicode code

Re: [rust-dev] Warn on useless comparisons

2012-10-22 Thread Nathan
This confused me, a rust neophyte, so I wanted to ask for clarification, inline below: I apologize this is a little off topic; is there a better venue for language-as-it-is learning versus design / implementation discussions? Has rust passed the threshold where those two topic groups split off

Re: [rust-dev] Warn on useless comparisons

2012-10-22 Thread Patrick Walton
On 10/22/12 1:59 PM, Nathan wrote: Is the indexing operation a primitive language implementation, or does it translate into a trait method or some other user-definable behavior? In the latter case, what is it's interface? (Nothing in the vec docs for 0.4 obviously implement v[i].) It

Re: [rust-dev] condition handling

2012-10-22 Thread Graydon Hoare
On 12-10-22 02:12 AM, Benjamin Striegel wrote: Could the RAII-styled second option be rewritten as follows? do |cond, handler| { cond.add(handler); do_some_stuff(); that_might_raise(); out_of_kittens(); }(OutOfKittens) |t| { UseAardvarksInstead

Re: [rust-dev] condition handling

2012-10-22 Thread Nathan
On Sat, Oct 20, 2012 at 5:31 AM, Matthieu Monrocq matthieu.monr...@gmail.com wrote: On Sat, Oct 20, 2012 at 1:37 PM, Gareth Smith garethdanielsm...@gmail.com wrote: Option 3 looks prettiest to me, but I like that in Option 1 the error-raising code comes before the error-handling code (based