Re: [rust-dev] On the use of unsafe

2014-09-21 Thread Cameron Zwarich
On Sep 20, 2014, at 11:29 PM, Tony Arcieri basc...@gmail.com wrote: He suggested using unsafe to call out when a SQL query is being made with a raw string. On the one hand I really liked the clarity of calling out passing a raw string to a SQL driver as being inherently unsafe, but on the

Re: [rust-dev] compiling Rust to C?

2014-07-18 Thread Cameron Zwarich
The biggest problem would be probably be handling stack unwinding (IIRC the LLVM C backend never tried to handle this either). The only option when targeting C is to use setjmp / longjmp, but that is going to be pretty inefficient. Alternatively you could just abort instead of unwinding.

Re: [rust-dev] Requesting information (about globs, macros, subtyping)

2014-07-18 Thread Cameron Zwarich
On Jul 16, 2014, at 10:54 AM, Gábor Lehel glaebho...@gmail.com wrote: 3. As far as I'm aware, subtyping in the current language arises only from subtyping of lifetimes. Where is this important? One example was mentioned in [Niko's recent blog

Re: [rust-dev] compiling Rust to C?

2014-07-18 Thread Cameron Zwarich
On Jul 18, 2014, at 9:52 AM, Josh Haberman jhaber...@gmail.com wrote: The only option when targeting C is to use setjmp / longjmp, but that is going to be pretty inefficient. Why do you think of setjmp/longjmp as inefficient? If you use the _setjmp/_longjmp variants that don't fiddle with

Re: [rust-dev] Syntax sugar: Vec Rc RefCell Box Foo - VecRcRefCellBoxFoo

2014-06-29 Thread Cameron Zwarich
This is pretty confusing to me because it’s associative in the opposite direction that function application is associative in functional languages with automatic currying. Cameron On Jun 28, 2014, at 3:48 PM, Benjamin Herr b...@0x539.de wrote: So, I've been vaguely concerned that types in a

Re: [rust-dev] Integer overflow, round -2147483648

2014-06-22 Thread Cameron Zwarich
For some applications, Rust’s bounds checks and the inability of rustc to eliminate them in nontrivial cases will already be too much of a performance sacrifice. What do we say to those people? Is it just that memory safety is important because of its security implications, and other forms of

Re: [rust-dev] self/mut self in traits considered harmful(?)

2014-06-22 Thread Cameron Zwarich
On Jun 16, 2014, at 3:19 PM, Patrick Walton pcwal...@mozilla.com wrote: On 6/16/14 3:17 PM, Cameron Zwarich wrote: I stated the right case, but the wrong reason. It’s not for vectorization, it’s because it’s not easy to reuse the storage of a matrix while multiplying into it. Wouldn't most

Re: [rust-dev] Integer overflow, round -2147483648

2014-06-22 Thread Cameron Zwarich
On Jun 22, 2014, at 8:52 PM, Patrick Walton pcwal...@mozilla.com wrote: On 6/22/14 8:46 PM, Daniel Micay wrote: It's for faster (but not free) array bounds checking. I don't think Rust will be able to use it because it unwinds on out-of-bounds rather than aborting, and it will be difficult to

Re: [rust-dev] Integer overflow, round -2147483648

2014-06-22 Thread Cameron Zwarich
On Jun 22, 2014, at 9:35 PM, Daniel Micay danielmi...@gmail.com wrote: An operation that can unwind isn't pure. It impedes code motion such as hoisting operations out of a loop, which is very important for easing the performance issues caused by indexing bounds checks. LLVM doesn't model the

Re: [rust-dev] Integer overflow, round -2147483648

2014-06-22 Thread Cameron Zwarich
On Jun 22, 2014, at 10:00 PM, Daniel Micay danielmi...@gmail.com wrote: On 23/06/14 12:49 AM, Cameron Zwarich wrote: On Jun 22, 2014, at 9:35 PM, Daniel Micay danielmi...@gmail.com mailto:danielmi...@gmail.com wrote: An operation that can unwind isn't pure. It impedes code motion

Re: [rust-dev] On Copy = POD

2014-06-21 Thread Cameron Zwarich
On Jun 20, 2014, at 11:06 PM, Nick Cameron li...@ncameron.org wrote: zwarich: I haven't thought this through to a great extent, and I don't think here is the right place to plan the API. But, you ought to still have control over whether an Rc pointer is copied or referenced. If you have an

Re: [rust-dev] Integer overflow, round -2147483648

2014-06-21 Thread Cameron Zwarich
On Jun 21, 2014, at 5:50 AM, Gregory Maxwell gmaxw...@gmail.com wrote: On Sat, Jun 21, 2014 at 5:18 AM, Diggory Hardy diggory.ha...@unibas.ch wrote: As far as I am aware, using theorem proving tools[1] to provide limits on value ranges is pretty hard and often computationally intensive to do

Re: [rust-dev] On Copy = POD

2014-06-21 Thread Cameron Zwarich
On Jun 21, 2014, at 2:15 PM, Nick Cameron li...@ncameron.org wrote: Ownership does not always work, graphs often appear in programming. When they do, you have to use Rc or Gc to cope. We shouldn't punish programmers who have these problems to deal with. Telling them to use ownership is

Re: [rust-dev] On Copy = POD

2014-06-21 Thread Cameron Zwarich
Another big problem with implicit copy constructors is that they make it very difficult to write correct unsafe code. When each use of a variable can call arbitrary code, each use of a variable can trigger unwinding. You then basically require people to write the equivalent of exception-safe

Re: [rust-dev] On Copy = POD

2014-06-20 Thread Cameron Zwarich
I sort of like being forced to use .clone() to clone a ref-counted value, since it makes the memory accesses and increment more explicit and forces you to think which functions actually need to take an Rc and which functions can simply take an . Also, if Rc becomes implicitly copyable, then

Re: [rust-dev] Why are generic integers not usable as floats?

2014-06-19 Thread Cameron Zwarich
Not all integer constants can be perfectly represented as floating-point values. What do you propose in that case, just a hard error? Cameron On Jun 19, 2014, at 4:02 PM, Matthew McPherrin m...@mcpherrin.ca wrote: This came up on IRC today, and it was something I've wondered in the past but

Re: [rust-dev] Fwd: self/mut self in traits considered harmful(?)

2014-06-16 Thread Cameron Zwarich
On Jun 16, 2014, at 2:24 PM, Patrick Walton pcwal...@mozilla.com wrote: On 6/16/14 1:04 PM, Sebastian Gesemann wrote: Am 16.06.2014 19:36, schrieb Patrick Walton: On 6/16/14 7:32 AM, Sebastian Gesemann wrote: Assuming this RFC is accepted: How would I have to implement Add for a custom type

Re: [rust-dev] Fwd: self/mut self in traits considered harmful(?)

2014-06-16 Thread Cameron Zwarich
On Jun 16, 2014, at 3:03 PM, Cameron Zwarich zwar...@mozilla.com wrote: On Jun 16, 2014, at 2:24 PM, Patrick Walton pcwal...@mozilla.com wrote: On 6/16/14 1:04 PM, Sebastian Gesemann wrote: Am 16.06.2014 19:36, schrieb Patrick Walton: On 6/16/14 7:32 AM, Sebastian Gesemann wrote: Assuming

Re: [rust-dev] GADT

2014-06-04 Thread Cameron Zwarich
There are at least two tricky aspects to adding GADTs in Rust: 1) Rust implements parametric polymorphism via monomorphization (duplicating polymorphic functions for each type), but GADTs are really only useful with polymorphic recursion, which requires a polymorphic function to be applied to a

Re: [rust-dev] Bring Back Type State

2014-06-04 Thread Cameron Zwarich
Is there a canonical example of encoding a state machine into Rust's substructural types? Cameron On Jun 4, 2014, at 10:14 PM, Brian Anderson bander...@mozilla.com wrote: Thank you for your suggestion, but typestate is not coming back. There is no room in the complexity budget for another

Re: [rust-dev] Calling a method while iterating over a field of the object

2014-06-01 Thread Cameron Zwarich
The simplest thing to do is probably to build an intermediate vector of vertices to insert and then push them all after you are done iterating over the edges. Cameron On Jun 1, 2014, at 12:48 PM, Nicholas Bishop nicholasbis...@gmail.com wrote: I'm looking for a little borrow-checker

Re: [rust-dev] Calling a method while iterating over a field of the object

2014-06-01 Thread Cameron Zwarich
() is not enough ? 2014-06-01 22:03 GMT+02:00 Cameron Zwarich zwar...@mozilla.com: The simplest thing to do is probably to build an intermediate vector of vertices to insert and then push them all after you are done iterating over the edges. Cameron On Jun 1, 2014, at 12:48 PM

Re: [rust-dev] Calling a method while iterating over a field of the object

2014-06-01 Thread Cameron Zwarich
:48 PM, Cameron Zwarich zwar...@mozilla.com wrote: `mut_iter` only gives you mutable references to the elements of the container; it doesn’t allow you to reborrow the container itself mutably inside of the loop. Cameron On Jun 1, 2014, at 1:39 PM, Christophe Pedretti christophe.pedre

Re: [rust-dev] A better type system

2014-05-31 Thread Cameron Zwarich
When writing an email stating “your programming language isn’t expressive enough”, it’s a good idea to include an example program that you would like to write that is rejected by the current type system. Then people replying to your email can give you some suggestions on how to best achieve

Re: [rust-dev] A better type system

2014-05-31 Thread Cameron Zwarich
FWIW, I think you could eliminate (c) by prohibiting mutation of sum types. What case are you thinking of for (e)? For (d), this would probably have to be distinguished from the current mut somehow, to allow for truly unique access paths to sum types or shared data, so you could preserve any