zatonovo / lambda.r

Functional programming in R
215 stars 14 forks source link

Parameter matching problem fix #33

Closed iwccsbfb closed 8 years ago

iwccsbfb commented 8 years ago

This PR calls the function directly from input, not from the manual parameter matching. With the following test case, there might still be issues with parameter matching when matching which function to call.

But calling the function now won't cause any problem.

Here is the test case: library(lambda.r)

f1 (a = 1, ...) %as% {
    vs <- list(...)
    print(vs)
    NULL
}
f1(1, 2, 3)

before the change:


> library(lambda.r)
> f1 (a = 1, ...) %as% {
+     vs <- list(...)
+     print(vs)
+     NULL
+ }
> f1(1, 2, 3)
[[1]]
[1] 1

[[2]]
[1] 2

[[3]]
[1] 3

NULL

After the change:

> library(lambda.r)
> f1 (a = 1, ...) %as% {
+     vs <- list(...)
+     print(vs)
+     NULL
+ }
> f1(1, 2, 3)
[[1]]
[1] 2

[[2]]
[1] 3

NULL
iwccsbfb commented 8 years ago

Reference: https://cran.r-project.org/doc/manuals/R-lang.html#Argument-matching We can apply this parameter matching procedure:

  1. Exact matching
  2. Partial matching
  3. Positional matching
iwccsbfb commented 8 years ago

There is bug. If there are unspecified default parameters, this would fail.