Appearance
| 1 | namespace Syntax.Process is | |
| 2 | // A function literal written with an argument pack spread out - | |
| 3 | // `(a, b) => ...` where the formal takes `T.. -> U` - is compiled | |
| 4 | // taking the pack's tuple directly, with its parameters unpacked on | |
| 5 | // entry. These are the literals that can be. | |
| 6 | class PACKED_LITERAL is | |
| 7 | is_eligible(function: Trees.Expressions.FUNCTION) -> bool static => is_eligible(function, 0) | |
| 8 | ||
| 9 | // `fixed_count` is how many parameters the formal takes of its | |
| 10 | // own before the pack; the literal's parameters after them are | |
| 11 | // the pack's elements. | |
| 12 | is_eligible(function: Trees.Expressions.FUNCTION, fixed_count: int) -> bool static is | |
| 13 | let arity = function.arguments.expressions.count - fixed_count | |
| 14 | ||
| 15 | if arity < 2 \/ arity > Semantic.ARGUMENT_PACK.MAXIMUM_ARITY then | |
| 16 | return false | |
| 17 | fi | |
| 18 | ||
| 19 | if function.is_recursive \/ function.contains_let_await then | |
| 20 | return false | |
| 21 | fi | |
| 22 | ||
| 23 | for a in function.arguments.expressions do | |
| 24 | let parameter = cast Trees.Expressions.VARIABLE?(a) | |
| 25 | ||
| 26 | if !parameter? \/ parameter.left? \/ parameter.pragmas? then | |
| 27 | return false | |
| 28 | fi | |
| 29 | od | |
| 30 | ||
| 31 | return true | |
| 32 | si | |
| 33 | si | |
| 34 | si |