Skip to content

Named parameters #176

Description

@pcingola

Add named parameters (with defaults) in functions and methods.
e.g.:

int f(int x, int y, int z=1) {
  return x + y + z
}

f(1, 2)         # Returns 4
f(1, 2, z=2)  # Retrns 5
  • Should bds use =, := or both?
f(1, 2, z=2)

or

f(1, 2, z := 2)

The former is more concise.

  • Bds should allow all parameters to be named? e.g., Using the previous definition of f(...) we should be able to write something like this?:
f(z=3, y=1, x=2)
  • How to implement this: The compiler should always create code to pass the parameters in order.

  • Execution order should be from left to right (as read from the program) regardless of the internal implementation. E.g.:

f( z=g(2), y=h(3), x=1)   # Invoke g(), then h(), and finally f()
f( x=1, y=h(3), z=g(2))   # Invoke h(), then g(), and finally f()

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions