diff --git a/docs/function-inlining.md b/docs/function-inlining.md index 7a9632b..c10b016 100644 --- a/docs/function-inlining.md +++ b/docs/function-inlining.md @@ -11,12 +11,13 @@ Luau's bytecode compiler (or VM?) is smart about inlining functions. We would ra Whether the goal is to improve instruction locality or perform context specific optimizations, function inlining can be a great resource for developers. Thankfully with the `-02` switch, Luau is able to automatically decide if code deserves to be inlined and optimize the code accordingly. To the best of our knowledge, exposing this to users directly could do more harm than good. Not only do these use cases only cater to a tiny subset of the language's users, it exposes our bytecode compiler to FILL when the larger subset who may not have a working understanding of the compiler adopts it. ```luau -@inline -- does not exist +@inline local function sum(lst: {[number]}) if #lst == 0 then return 0 else return lst[1] + sum(lst) -- bad rec + end end local s = sum({1, 2, 3}) @@ -35,6 +36,5 @@ None (yet). None (yet). ## Alternatives - Prior to now, the team has considered some designs to make function inlining work effectively in Luau and is still hopeful that this may be possible sometime in the future. Till then, we suggest opening github issues with code samples of legitimate cases that we can use to further improve Luau's automatic (function inlining and unrolling) optimizations.