[Rd] more special completions

Vitalie S. vitosmail at rambler.ru
Sat Aug 22 11:28:25 CEST 2009


>>  Not sure, but another example may be a class dependent completion for
>> generic functions depending on first argument. Like print(df,... )  
>> where df
>> a data.frame to complete, digits = NULL, quote = FALSE, right = TRUE,
>> row.names = TRUE instead of only (x,...).
>
> That sort of already happens (have you tried?),

Oh, sorry, I have been confusing display of args list in emacs with R  
completions facilities. Emacs implements that directly through  
try(args(function).

>  but instead of
> print.data.frame, it gives you arguments of all print methods (only
> for S3 generics though). Finding the right signature needs evaluation
> of the right (usually first, but not necessarily) argument, which may
> actually involve another function call. Inheritance makes things more
> complicated. I'm not sure it's worth the overhead.
>

If custom function as Romain proposed, had an argument of all names typed  
after "(" (say "fArgs"), a whole range of possibilities opens up. At least  
one case when evaluation is not that demanding is new(); new() could  
generate completions for classes if fArgs is empty and completions for  
slots of class fArgs[1] otherwise.

Not to mention that various RGuis could use this facility to generate the  
list of context dependent arguments for in-line functions. Wouldn't that  
be great?!


What concerns S4 methods, findMethodSignatures is already there:
require("Matrix")
formals(getMethod("*", findMethodSignatures("*")[4, ]))
$e1
$e2

so it seems to me (a simple user) like the main "overhead" would be to  
implement custom functions with fArgs argument.



Vitalie
>-Deepayan


--



More information about the R-devel mailing list