Here is my proposed plan for mode removal. The eventual goal is to pass all parameters by value. The idea is to proceed in two steps.

In the first phase, we migrate the codebase over so that only two modes are in use: the default mode or the by-copy mode (+). By-copy will be used for unique pointers (including vecs, strs, fn~) which are expensive to copy and which the callee wishes to take ownership of. The default mode will be used for all other values. If you wish to borrow a unique pointer, then you use a borrowed pointer.

This migration will be done piecemeal. There will be a lint mode (I am working on it now) which warns you about arguments that do not follow this convention. I'll send e-mail when it's ready. The idea will be to migrate modules or functions one at a time and then set the lint mode to prevent regression.

Once the migration is complete, we can simply pass all arguments by value.

There is one other factor, which is the changing of alt bindings to make by-ref explicit. I imagine this will proceed in a similar fashion. I will add an optional ref keyword that (currently) has no significance and a lint mode that warns if it is not used in the appropriate places. We can then switch over once refs are added where they need to be.

Sound good?


Niko
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to