Re: [rust-dev] We can do without (immutable) by-alias parameters

2011-09-09 Thread Marijn Haverbeke
Update: The approach sketched earlier does not work out because it is possible for a function to take a parameterized type without the caller knowing that it does. (For example, a fnT(x: fn(T)), when given a function fn(int), will call it with the argument given by reference, since it sees it as

Re: [rust-dev] We can do without (immutable) by-alias parameters

2011-09-09 Thread Patrick Walton
On 9/9/11 9:14 AM, Marijn Haverbeke wrote: Update: The approach sketched earlier does not work out because it is possible for a function to take a parameterized type without the caller knowing that it does. (For example, a fnT(x: fn(T)), when given a function fn(int), will call it with the

[rust-dev] We can do without (immutable) by-alias parameters

2011-09-07 Thread Marijn Haverbeke
Now that structural types are always passed by reference, we can pass all values conceptually by alias (i.e., without doing a take/drop on them). The current alias analysis can be used to insert a refcount bump or explicit copy on the caller side in those cases where it can't prove the aliasing is

Re: [rust-dev] We can do without (immutable) by-alias parameters

2011-09-07 Thread Marijn Haverbeke
While this is attractive from the perspective of having the right defaults, it also makes the semantics of the code at a glance more subtle. The semantics are not effected at all -- both with 'structurally immutable' and with immediate values, it is not observable whether the parameter was

Re: [rust-dev] We can do without (immutable) by-alias parameters

2011-09-07 Thread Patrick Walton
On 09/07/2011 07:18 AM, Marijn Haverbeke wrote: While this is attractive from the perspective of having the right defaults, it also makes the semantics of the code at a glance more subtle. The semantics are not effected at all -- both with 'structurally immutable' and with immediate values, it

Re: [rust-dev] We can do without (immutable) by-alias parameters

2011-09-07 Thread Marijn Haverbeke
These concerns are why I advanced the suggestion earlier: make no sigil mean immutable alias semantics, but the compiler may choose to promote to value if the value is immutable and small, but have an explicit copy sigil mean always copy. I see. This is what I meant when I said we can

Re: [rust-dev] We can do without (immutable) by-alias parameters

2011-09-07 Thread Graydon Hoare
On 11-09-07 07:18 AM, Marijn Haverbeke wrote: But if you ignore the actual binary calling convention, you can think of this proposal as passing everything by reference. Immediates will in fact be passed by value, since this is more efficient, but the difference is not observable in regular,

Re: [rust-dev] We can do without (immutable) by-alias parameters

2011-09-07 Thread Marijn Haverbeke
A mystery-heuristic that programmers can't depend on is much less attractive. Users are going to write unsafe code that occasionally observes the distinction. I don't want to be hiding this. The only point where I suggested a heuristic was for when to emit warning for implicit copying. The