BigDataScript icon indicating copy to clipboard operation
BigDataScript copied to clipboard

Named parameters

Open pcingola opened this issue 5 years ago • 0 comments

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()

pcingola avatar May 02 '19 01:05 pcingola