From vitosmail at rambler.ru  Sat Aug 22 11:28:25 2009
From: vitosmail at rambler.ru (Vitalie S.)
Date: Sat, 22 Aug 2009 11:28:25 +0200
Subject: [Rd] more special completions
In-Reply-To: <eb555e660908211142p4c7954b4p4993bfc2fc052b1f@mail.gmail.com>
References: <4A8E66FF.6000201@dbmail.com>
	<op.uy0xe6epdacko8@tir-070312.staff.few.eur.nl>
	<eb555e660908211142p4c7954b4p4993bfc2fc052b1f@mail.gmail.com>
Message-ID: <op.uy14lngtdacko8@tir-070312.staff.few.eur.nl>


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


--



[Rd] more special completions
Vitalie S.