[rust-dev] conditional compilation and macros

2014-04-04 Thread Maciej Dziardziel
I am trying to define macro that would only expand to anything if certain cfg option is defined, otherwise it should be no-op, but I cannot find a way to do it. Pretty much I want some form of #ifdef. The closest thing I can find is to enclose generated code in a function, and just do this: #cfg(

Re: [rust-dev] Reminder: ~[T] is not going away

2014-04-04 Thread Manu Thambi
Most of your comments below do not apply to a properly implemented negative index scheme. So, it seems clear to me, that I haven't been able to get it across to you. I guess we can both agree that spending more time on this thread is unproductive, especially since the real question is whether

Re: [rust-dev] Reminder: ~[T] is not going away

2014-04-04 Thread Daniel Micay
On 04/04/14 04:12 PM, Manu Thambi wrote: > > On 04/04/2014 02:51 PM, Daniel Micay wrote: >> >> Storing at a negative index removes the cost at indexing, but not >> elsewhere. It still consumes more memory and makes `push` slower, >> especially since it has to do more than more offset based on alig

[rust-dev] Some help needed in Vector of enum conversion

2014-04-04 Thread Philippe Delrieu
Hello, I've some problem to find a solution for something I want to do with a vector of enum. This is an example of what I want to do: trait Base{ fn set_something(&mut self); } struct FirstThink; impl Base for FirstThink{ fn set_something(&mut self){} } struct SecondThink;

Re: [rust-dev] Reminder: ~[T] is not going away

2014-04-04 Thread Manu Thambi
On 04/04/2014 02:51 PM, Daniel Micay wrote: Storing at a negative index removes the cost at indexing, but not elsewhere. It still consumes more memory and makes `push` slower, especially since it has to do more than more offset based on alignment with at least one overflow check. In the "nega

Re: [rust-dev] Building a static array of pointers

2014-04-04 Thread Alex Crichton
As you've discovered in bug #13325, dealing with external constants in static expressions is sometimes a little tricky. I would avoid casting for now (as happens in the bug) in favor of stronger types. For example, this compiles and runs for me: extern { fn foo(); fn bar();

[rust-dev] Building a static array of pointers

2014-04-04 Thread Vladimir Pouzanov
Is it possible to port the following C code to rust? __attribute__ ((section(".isr_vector"))) void (* const isr_vector_table[])(void) = { &_stack_base, main, // Reset isr_nmi, // NMI isr_hardfault,// Hard Fault 0,// CM3 Memory Management

Re: [rust-dev] Reminder: ~[T] is not going away

2014-04-04 Thread Daniel Micay
On 04/04/14 01:50 PM, Manu Thambi wrote: > > As Nathan mentioned, the capacity is stored at a negative offset to the > pointer to the heap. Storing at a negative index removes the cost at indexing, but not elsewhere. It still consumes more memory and makes `push` slower, especially since it has to

Re: [rust-dev] Reminder: ~[T] is not going away

2014-04-04 Thread Manu Thambi
Thanks for the detailed reply. You clearly have done a lot of work on the code, and I have just been following the mailing lists for a while. So, I might be misunderstanding something here. On 04/04/2014 11:37 AM, Daniel Micay wrote: It bloats the code size by requiring extra overflow checks

Re: [rust-dev] Reminder: ~[T] is not going away

2014-04-04 Thread Daniel Micay
On 04/04/14 10:51 AM, Manu Thambi wrote: > >> Needing to use a header seriously hurts the performance. The new >> vector is 7x faster at pushing elements when space isn't reserved >> compared to the old one, all due to leaving off the length/capacity >> header. The overhead would be less if it sto

Re: [rust-dev] Reminder: ~[T] is not going away

2014-04-04 Thread Manu Thambi
Needing to use a header seriously hurts the performance. The new vector is 7x faster at pushing elements when space isn't reserved compared to the old one, all due to leaving off the length/capacity header. The overhead would be less if it stored the capacity inside *and* outside the vector,

Re: [rust-dev] Tagged integral & floating-point types

2014-04-04 Thread Tommi Tissari
> On 04 Apr 2014, at 12:30, Vadim Chugunov wrote: > > Regarding the original idea: Why use a whole bit, when you only need one > value out of all possible type's values? For example, for floats, one of > the NaNs could be used for this purpose without any issues with overflow as > would hap

Re: [rust-dev] Reminder: ~[T] is not going away

2014-04-04 Thread Daniel Micay
On 03/04/14 11:48 PM, Nathan Myers wrote: > >>> Perhaps the best thing is to wait a month (or two or three) until DST >>> is more of a reality and then see how we feel. >> >> Are you thinking we should also wait before converting the current uses >> of ~[T] to Vec? Doing the migration gives us the

Re: [rust-dev] matching on a few bits in int

2014-04-04 Thread Vladimir Pouzanov
I've submitted an RFC for this one: https://github.com/rust-lang/rfcs/pull/29 On Sat, Mar 29, 2014 at 6:14 PM, Bill Myers wrote: > I think the best solution is to add uN and sN types where N is not a power > of two, which LLVM should already support. > > Then you can write your match like this:

Re: [rust-dev] Tagged integral & floating-point types

2014-04-04 Thread Vadim Chugunov
Regarding the original idea: Why use a whole bit, when you only need one value out of all possible type's values? For example, for floats, one of the NaNs could be used for this purpose without any issues with overflow as would happen in your proposal. Regarding "which types?": Perhaps this sh

[rust-dev] A More Detailed Tour of the Rust Compiler

2014-04-04 Thread Tom Lee
Hey folks, I took the slides from my talk at last week's PDX-Rust meetup & slapped together a blog post that covers some of the innards of the Rust compiler in a little more detail: http://tomlee.co/2014/04/03/a-more-detailed-tour-of-the-rust-compiler/ It kind of reads somewhere between a high l

Re: [rust-dev] Tagged integral & floating-point types

2014-04-04 Thread Tommi
Okay. But first I'd like to get some input on for what types T should the language guarantee this suggested optimization for Option. Because the optimization could be done for any type T from which at least one or more of these new primitive data types is accessible. But it's not clear whether o