On 03/03/14 07:27 PM, Carter Schonwald wrote: > Trust me when I say that monadic bind for simple things like option > should always be inlined away. In any sane language. This holds just > as true in Haskell as in rust. I have many nontrivial examples of > monadic bit fiddling codes in Haskell that generate the exact same > assembly id expect c to generate. > > That said, not every monad is as simple as andThenOption. You may not > want to inline monadic bind significantly more complex/interesting monads. > > That said, any fault in Inlining things which are cheap and suitable to > inline should be treated as being faults of the optimizer and constitute > examples to include In a optimizer performance test suite, rather than > an argument against higher order type traits or abstractions.
Static call inlining is reliable and will always occur if the function is below the threshold and does not use C-style varargs. It's far from guaranteed that indirect calls will be inlined and they often aren't. Rust has no unboxed closures without indirect calls... so abstractions using closures are often not free of cost.
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev