empirical-lang icon indicating copy to clipboard operation
empirical-lang copied to clipboard

Default and named arguments

Open chrisaycock opened this issue 5 years ago • 0 comments

From the roadmap (#1), we want default and named arguments:

func foo(x: Int64, y: Int64 = 3): return x + y end

foo(7)
foo(7, 11)
foo(7, y=11)
foo(x=7, y=11)
foo(x=7)
foo(y=11, x=7)

This requires the following changes:

  • Parse must allow for default and named arguments.
  • AST/HIR must carry default and named arguments.
  • Sema must match function call types by "filling-in the blanks" when a defaulted argument is missing, and must "line-up" named arguments that might be in the wrong order/position.
  • Codegen must reorder named arguments to be in the correct position, and must pass-in defaulted arguments when needed.

Changes only apply to the Empirical compiler. No action is required for VVM.

chrisaycock avatar Aug 21 '19 19:08 chrisaycock