[rust-dev] How to join together C and Rust code?

2012-04-16 Thread Alexander Stavonin
Is it possible to include into the one crate as Rust as C code? ___ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev

[rust-dev] How to allocate record on memory?

2012-04-16 Thread Alexander Stavonin
I have a C function with void* argument wich will be passed to callback and I want to pass Rust record as the argument. The question is, how to allocate record on memory but not on the stack? I've tried a lot of different ways, but with same result: in callback function record data looked as

Re: [rust-dev] How to join together C and Rust code?

2012-04-16 Thread Graydon Hoare
On 12-04-16 06:01 AM, Alexander Stavonin wrote: Is it possible to include into the one crate as Rust as C code? Rust can call C by declaring the C functions within a suitably named rust native module. C can call rust only by rust passing C a pointer to a 'crust' function. Currently the rust

Re: [rust-dev] How to join together C and Rust code?

2012-04-16 Thread Brian Anderson
On 04/16/2012 06:01 AM, Alexander Stavonin wrote: Is it possible to include into the one crate as Rust as C code? Yes it is possible. There's no explicit support for it but native modules may refer to static libraries and it's relatively easy to link arbitrary static libraries into a crate.

Re: [rust-dev] Fall-through in alt, breakcontinue by label

2012-04-16 Thread Graydon Hoare
On 12-04-15 06:23 PM, Joe Groff wrote: On Sun, Apr 15, 2012 at 6:19 PM, Patrick Walton pwal...@mozilla.com wrote: Only if LLVM's optimizer is smart enough to turn that code into a goto-based state machine. I'm not sure if it is. (Of course, if it's not, that's possibly fixable...) IIRC

Re: [rust-dev] Fall-through in alt, breakcontinue by label

2012-04-16 Thread Patrick Walton
On 4/16/12 11:46 AM, Graydon Hoare wrote: They're already present (were from the beginning) but they broke when we shifted from rustboot (hand-rolled code generator) to rustc (LLVM). It turns out that you have to adopt a somewhat pessimistic ABI in all cases if your functions are to be

Re: [rust-dev] Fall-through in alt, breakcontinue by label

2012-04-16 Thread Graydon Hoare
On 12-04-16 11:49 AM, Patrick Walton wrote: On 4/16/12 11:46 AM, Graydon Hoare wrote: They're already present (were from the beginning) but they broke when we shifted from rustboot (hand-rolled code generator) to rustc (LLVM). It turns out that you have to adopt a somewhat pessimistic ABI in

Re: [rust-dev] 2 possible simplifications: reverse application, records as arguments

2012-04-16 Thread Graydon Hoare
On 12-04-13 11:07 PM, Kobi Lurie wrote: one is reverse application. it's actually logical and might simplify things. (similar to extension methods in c#) there are no classes, but a syntax like: obj.method(b,c) still exists. from what I could tell, the function is really method(obj,b,c), and

[rust-dev] -L flag now also used for native libraries

2012-04-16 Thread Brian Anderson
Hey. Using bindings has been complicated by our lack of configuration for locating native libraries. Until now we've had to hack in `link_args` attributes in order to specify where native libraries live. Today I checked in a change that makes the `-L` flag also apply to native libraries, so

Re: [rust-dev] 2 possible simplifications: reverse application, records as arguments

2012-04-16 Thread Nate Bragg
On Mon, Apr 16, 2012 at 3:22 PM, Graydon Hoare gray...@mozilla.com wrote: - Our records are order-sensitive, to be C-structure compatible. Keyword arguments are usually argued-for (as you are doing here) as a way to make function arguments order-insensitive. We'd need to decide whether

Re: [rust-dev] Fall-through in alt, breakcontinue by label

2012-04-16 Thread Stefan Plantikow
Hi, Am Montag, 16. April 2012 um 20:54 schrieb Graydon Hoare: On 12-04-16 11:49 AM, Patrick Walton wrote: On 4/16/12 11:46 AM, Graydon Hoare wrote: They're already present (were from the beginning) but they broke when we shifted from rustboot (hand-rolled code generator) to rustc

Re: [rust-dev] Fall-through in alt, breakcontinue by label

2012-04-16 Thread Graydon Hoare
On 12-04-16 04:07 PM, Stefan Plantikow wrote: Some algorithms just yearn for being written in a recursive style. Or state-machine style, yeah. IMO the use case for tail calls is more state machines than recursion. But both can be rewritten without. I think it's just a style issue; I don't

Re: [rust-dev] paring back the self type to be, well, just a type

2012-04-16 Thread Nicholas Matsakis
I think that if we want to support something like the `self` type, we need to go all out and truly support higher-kinded types. The current system is too weak to really express anything useful. I mean, you can write useful ifaces, but you can't work with them in a generic fashion. For

Re: [rust-dev] Functions overloading

2012-04-16 Thread Stefan Plantikow
Hi, Am Donnerstag, 12. April 2012 um 15:47 schrieb Niko Matsakis: Not only that, but it adds an extra layer of complexity for type inferencing, which quite frankly is already complex enough. That said, you can do a limited form of overloading using impls: impl methods for int { fn

Re: [rust-dev] Functions overloading

2012-04-16 Thread Niko Matsakis
On 4/16/12 5:58 PM, Stefan Plantikow wrote: I think it would be nice too have some syntax support for building ifaces like that, perhaps via macros. I can see this approach being useful in cases of multiple inputs. In any case, it reminds me of this bug:

[rust-dev] iface type parameter restrictions

2012-04-16 Thread Steven Blenkinsop
Motivated by the thread paring back the self type to be, well, just a type https://mail.mozilla.org/pipermail/rust-dev/2012-April/001661.html I decided to see how far I could get toward implementing monads given the self type [constructor] as-is. I ran into several things that got in the way, so

Re: [rust-dev] iface type parameter restrictions

2012-04-16 Thread Niko Matsakis
On 4/16/12 6:23 PM, Steven Blenkinsop wrote: Motivated by the thread paring back the self type to be, well, just a type https://mail.mozilla.org/pipermail/rust-dev/2012-April/001661.html I decided to see how far I could get toward implementing monads given the self type [constructor] as-is. I