You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The distinction between && and ++ (by address and by value) is clearly an annoyance, and can be removed for Rust functions now that generics are monomorphized.
I maintain that by-move is strictly less useful than by-copy, and should probably also be removed. By-copy is still needed to efficiently construct things, unless we want to force callers of constructor functions to explicitly move things (some(move my_local_vec)) or pay for a copy, which seems unfortunate to me.
Another thing is that having explicit control over passing style for native functions is necessary. If you have a multi-word-sized thing, you sometimes want to pass it by pointer, and sometimes as a whole, depending on the signature of the native. One option is to always pass things by-value to natives, and make the argument type an unsafe pointer when calling by pointer. Again, this puts a burden on the caller, but native functions are usually wrapped by a rust adaptor function already, so this is probably not all that bad. An unfortunate side effect is that taking the value of a native function would require wrapping it in some kind of adapter, because its calling convention isn't the same as that of a Rust function with the same signature.
My proposal would be: Keep modes, but only have copy and normal, where by-copy gives the callee ownership of the argument (moving when possible, making a copy otherwise), and normal leaves ownership with the caller. Automatically pick a suitable passing convention based on the type of the value (immediates are passed directly, all other things are passed by pointer), except for (directly called) native functions, which never take things by-pointer, as outlined above.
The text was updated successfully, but these errors were encountered:
Modes are going away. Region pointers handle the case explicitly and users are perpetually confused by the compiler choosing by-ref or by-val on their behalf.
The distinction between && and ++ (by address and by value) is clearly an annoyance, and can be removed for Rust functions now that generics are monomorphized.
I maintain that by-move is strictly less useful than by-copy, and should probably also be removed. By-copy is still needed to efficiently construct things, unless we want to force callers of constructor functions to explicitly move things (
some(move my_local_vec)
) or pay for a copy, which seems unfortunate to me.Another thing is that having explicit control over passing style for native functions is necessary. If you have a multi-word-sized thing, you sometimes want to pass it by pointer, and sometimes as a whole, depending on the signature of the native. One option is to always pass things by-value to natives, and make the argument type an unsafe pointer when calling by pointer. Again, this puts a burden on the caller, but native functions are usually wrapped by a rust adaptor function already, so this is probably not all that bad. An unfortunate side effect is that taking the value of a native function would require wrapping it in some kind of adapter, because its calling convention isn't the same as that of a Rust function with the same signature.
My proposal would be: Keep modes, but only have
copy
andnormal
, where by-copy gives the callee ownership of the argument (moving when possible, making a copy otherwise), and normal leaves ownership with the caller. Automatically pick a suitable passing convention based on the type of the value (immediates are passed directly, all other things are passed by pointer), except for (directly called) native functions, which never take things by-pointer, as outlined above.The text was updated successfully, but these errors were encountered: