Github user felixcheung commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14558#discussion_r74694116
  
    --- Diff: R/pkg/R/functions.R ---
    @@ -1143,7 +1139,7 @@ setMethod("minute",
     #' @export
     #' @examples \dontrun{select(df, monotonically_increasing_id())}
     setMethod("monotonically_increasing_id",
    -          signature(x = "missing"),
    +          signature(),
    --- End diff --
    
    Hmm, I looked into this a bit
    
    in below, "a" is what we have orginially
    ```
    setGeneric("a", function(x) { standardGeneric("a") } )
    setMethod("a", signature(x = "missing"), function() { 1 })
    > a()
    [1] 1
    > a(1)
    Error in (function (classes, fdef, mtable)  :
      unable to find an inherited method for function ‘a’ for signature 
‘"numeric"’
    > showMethods(a)
    Function: a (package .GlobalEnv)
    x="missing"
    
    setGeneric("b", function(x = "missing") { standardGeneric("b") } )
    setMethod("b", signature("missing"), function() { 1 })
    > b()
    [1] 1
    > b(1)
    Error in (function (classes, fdef, mtable)  :
      unable to find an inherited method for function ‘b’ for signature 
‘"numeric"’
    > showMethods(b)
    Function: b (package .GlobalEnv)
    x="missing"
    
    setGeneric("tt", function(...) { standardGeneric("tt") } )
    setMethod("tt", signature(), function() { 1 })
    > tt(1)
    Error in .local(...) : unused argument (1)
    > tt("emme")
    Error in .local(...) : unused argument ("emme")
    > showMethods(tt)
    Function: tt (package .GlobalEnv)
    ...="ANY"
    ...="character"
        (inherited from: ...="ANY")
    ...="numeric"
        (inherited from: ...="ANY")
    ```
    
    I think the issue with `setMethod("foo", signature(), function() { 1 })` 
are two folds:
    1. The error message when calling the function with a parameter is less 
clear than "unable to find function for signature ‘"numeric"’"
    2. S4 method is automatically generated for each parameter type that it is 
called with (see "numeric" or character" from showMethods)
    
    So perhaps "b" is a better approach?
    Unfortunately we still have to "document" a parameter or `...` in either 
case as `setGeneric` refuse to take it otherwise.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to