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

2012-10-23 Thread Henri Sivonen
On Mon, Oct 22, 2012 at 7:08 PM, Graydon Hoare gray...@mozilla.com wrote: 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

[rust-dev] Object orientation without polymorphism

2012-10-23 Thread Henri Sivonen
Now that classes are gone, what’s the right way to group a bunch of fields and methods when polymorphism is not needed? That is, if I have a struct with some fields, some constants that make sense in the context of that struct and some methods that operate on the struct, how should I group them

Re: [rust-dev] Object orientation without polymorphism

2012-10-23 Thread Lucian Branescu
I think it's possible to implement methods on a struct directly, without a trait in between. On 23 October 2012 13:17, Henri Sivonen hsivo...@iki.fi wrote: Now that classes are gone, what’s the right way to group a bunch of fields and methods when polymorphism is not needed? That is, if I

Re: [rust-dev] Object orientation without polymorphism

2012-10-23 Thread Henri Sivonen
On Tue, Oct 23, 2012 at 3:20 PM, Lucian Branescu lucian.brane...@gmail.com wrote: I think it's possible to implement methods on a struct directly, without a trait in between. This does not compile: struct Foo { x: i32, y: i32, fn bar() { }, } -- Henri Sivonen hsivo...@iki.fi

Re: [rust-dev] Object orientation without polymorphism

2012-10-23 Thread Tim Taubert
On 10/23/2012 02:20 PM, Lucian Branescu wrote: I think it's possible to implement methods on a struct directly, without a trait in between. Indeed, like this: struct Storage { ... } impl Storage { fn listen() { ... } } - Tim On 23 October 2012 13:17, Henri Sivonen hsivo...@iki.fi

Re: [rust-dev] Object orientation without polymorphism

2012-10-23 Thread Lucian Branescu
Something like this http://pcwalton.github.com/blog/2012/08/08/a-gentle-introduction-to-traits-in-rust/ On 23 October 2012 13:23, Henri Sivonen hsivo...@iki.fi wrote: On Tue, Oct 23, 2012 at 3:20 PM, Lucian Branescu lucian.brane...@gmail.com wrote: I think it's possible to implement methods on

Re: [rust-dev] Object orientation without polymorphism

2012-10-23 Thread Henri Sivonen
On Tue, Oct 23, 2012 at 3:24 PM, Tim Taubert ttaub...@mozilla.com wrote: struct Storage { ... } impl Storage { fn listen() { ... } } Thanks. Is there a way to scope constants under the namespace of a struct? -- Henri Sivonen hsivo...@iki.fi http://hsivonen.iki.fi/

Re: [rust-dev] Object orientation without polymorphism

2012-10-23 Thread Julien Blanc
Lucian Branescu a écrit : Something like this http://pcwalton.github.com/blog/2012/08/08/a-gentle-introduction-to-traits-in-rust/ Very nice introduction. The only question that arises for me (coming from c++ ground and comparing this to c++ templates) is why trait implementation is made

Re: [rust-dev] How to get code of snapshot compiler

2012-10-23 Thread Paul Stansifer
The code in the Rust repo *is* the code for the snapshot compiler. Since the Rust compiler is written in Rust, everyone has to download a binary version of the compiler in order to compile their own copy. In the distant past, there existed an Ocaml compiler for Rust, which was how the process was

Re: [rust-dev] condition handling

2012-10-23 Thread Benjamin Striegel
Thanks, this is very informative. I also have a few questions, so I apologize in advance if I betray my ignorance. The TLS key boilerplate would be rather unfortunate if it was forced to be in both the API provider and the API consumer, would it be possible to stick it in the io mod and then do

[rust-dev] Looping again but incrementing the loop counter first

2012-10-23 Thread Henri Sivonen
In C, Java, JS, etc., using |continue| in a |for| loop evaluates the update expression before going back to the condition. That is, in a C |for|, |continue| is a goto to the bottom of the loop and |continue| in |while| is a goto to right before the condition. What’s the correct way to write the

Re: [rust-dev] condition handling

2012-10-23 Thread Jeffery Olson
How will users of an API be expected to discover all the possible signals that are available to be trapped from any given function? This is an existent problem on any platform with unchecked exceptions (C#/.NET, python, ruby, etc). There's no good answer, besides auditing of callee code or

Re: [rust-dev] condition handling

2012-10-23 Thread David Rajchenbach-Teller
I suspect that we can add optional static analysis (à la OCamlExc or Haskell Catch), executed as part of a strengthened build system. Cheers, David On 10/23/12 4:58 PM, Jeffery Olson wrote: How will users of an API be expected to discover all the possible signals that are available to be

Re: [rust-dev] Object orientation without polymorphism

2012-10-23 Thread Patrick Walton
On 10/23/12 5:30 AM, Henri Sivonen wrote: Is there a way to scope constants under the namespace of a struct? Not at the moment. You can work around it by making the constants pure inline functions. I don't think it would be hard to add this now that we merged the type and module

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

2012-10-23 Thread Patrick Walton
On 10/23/12 4:17 AM, Henri Sivonen wrote: That would work for match but doesn’t work for using char literals for initializing u8 arrays and the like. Absent the ability to use char literals the same way unsuffixed integer literals work, I guess the easiest path forward is for me to generate hex

Re: [rust-dev] condition handling

2012-10-23 Thread David Rajchenbach-Teller
As most people around here, I would prefer avoiding #2 and its magic variable, unless we can wrap it in a nice syntax extension/macro. Between #1 and #3, I prefer #1 for the exact reason James Boyden dislikes it: it lets me concentrate on the most common path, without having to deal with

Re: [rust-dev] condition handling

2012-10-23 Thread David Rajchenbach-Teller
On 10/23/12 3:44 AM, Graydon Hoare wrote: On 12-10-21 09:50 PM, Benjamin Striegel wrote: If it's not too much trouble, a complete example (using any one of the proposed syntaxes) would be enlightening. I'm still having a hard time imagining how OutOfKittens is defined, and how do_some_stuff et

Re: [rust-dev] condition handling

2012-10-23 Thread Daniel Patterson
On Oct 23, 2012, at 12:00 PM, David Rajchenbach-Teller wrote: // Boilerplate for declaring TLS key fn missing_file_key(_x: @HandlerPath,Reader) { } I do not understand this line. TLS storage needs a unique key to identify it. Right now, the way that is done, as I understand it, is with the

Re: [rust-dev] Object orientation without polymorphism

2012-10-23 Thread Matthieu Monrocq
On Tue, Oct 23, 2012 at 2:46 PM, Julien Blanc wh...@tgcm.eu wrote: Lucian Branescu a écrit : Something like this http://pcwalton.github.com/blog/2012/08/08/a-gentle-introduction-to-traits-in-rust/ Very nice introduction. The only question that arises for me (coming from c++ ground and

Re: [rust-dev] Looping again but incrementing the loop counter first

2012-10-23 Thread Brian Anderson
On 10/23/2012 06:52 AM, Henri Sivonen wrote: In C, Java, JS, etc., using |continue| in a |for| loop evaluates the update expression before going back to the condition. That is, in a C |for|, |continue| is a goto to the bottom of the loop and |continue| in |while| is a goto to right before the

Re: [rust-dev] condition handling

2012-10-23 Thread Graydon Hoare
On 12-10-23 08:30 AM, David Rajchenbach-Teller wrote: Finally, I would like to be sure that I understand one thing: as far as I understand, this mechanism is not designed to handle any kind of concurrent condition, i.e. a condition raised in one task and best handled in another. The mechanism

Re: [rust-dev] condition handling

2012-10-23 Thread David Rajchenbach-Teller
On 10/23/12 10:01 PM, Graydon Hoare wrote: On 12-10-23 08:30 AM, David Rajchenbach-Teller wrote: Finally, I would like to be sure that I understand one thing: as far as I understand, this mechanism is not designed to handle any kind of concurrent condition, i.e. a condition raised in one

Re: [rust-dev] condition handling

2012-10-23 Thread Graydon Hoare
On 12-10-23 06:36 AM, Benjamin Striegel wrote: Thanks, this is very informative. I also have a few questions, so I apologize in advance if I betray my ignorance. The TLS key boilerplate would be rather unfortunate if it was forced to be in both the API provider and the API consumer, would it

Re: [rust-dev] condition handling

2012-10-23 Thread Graydon Hoare
On 12-10-23 09:14 AM, David Rajchenbach-Teller wrote: Couldn't |missing_file| itself be the TLS key? Probably. I believe it wasn't done that way for two reasons: - Data addresses can be recycled by accident, due to stack/heap reuse. Code segment addresses are Really Unique at load time.