2 ms·
Never read "smallcultfollowing" before. The "implicitly copyable" problem is amusing. That was dealt with by Wirth in Modula 1 with the rule "if the programmer
by Animats 10y ago
Never read "smallcultfollowing" before.
The "implicitly copyable" problem is amusing. That was dealt with by Wirth in Modula 1 with the rule "if the programmer can't tell, it's up to the compiler". Thus, non-writable objects could be passed either by reference or by copy, depending on object size. This was up to the compiler. The usual rule was that anything up to 2 words in size was copied. Since the called function couldn't change the value, it didn't matter.
This avoids philosophical gyrations. You want a rule that says you can copy ints and floats, for performance reasons. Trying to reach that via type theory makes it harder. It's an optimization.
- pcwalton 10y agoWe tried making copy/move an optimization. The number of useless copies that ended up in the resulting code was absurd. You think compile times are bad now…
- Animats 10y agoYou mean there were lots of copies that made it to the back end, only to be converted to non-mutable references late in the compilation process?
- pcwalton 10y agoHow do you convert copies to non-mutable references? That involves proving things about aliasing. Even in Rust that is not that easy…
- Animats 10y agoThe other way round. Sometimes you want to convert non-mutable references to non-mutable copies. This is almost always a win for int, float, etc., and usually a win for anything up to 8 bits on a modern processor.
- uabstraction 10y agoI'm going to nitpick and suggest that you almost certainly meant 8 _bytes_.
- dbaupp 10y agoFortunately there's no need to have read all of the (very interesting) archives of Niko's blog in this case, as the parent article linked to that post in the relevant section too.