Point well taken --- grid::gpar() is also a good example; I'll make
use of your suggestion in my future coding.

Best,

baptiste

On 27 February 2010 15:02, Barry Rowlingson
<b.rowling...@lancaster.ac.uk> wrote:
> On Sat, Feb 27, 2010 at 11:29 AM, Gabor Grothendieck
> <ggrothendi...@gmail.com> wrote:
>> Or use modifyList which is in the core of R.
>
>  All these solutions appear to be adding on more and more code with
> less and less semantics. Result: messy code which is harder to read
> and debug.
>
>  It seems that the arguments should have proper constructors with
> meaningful names. A bit like an optimisation function with a control
> argument. What's better:
>
>  o = optimmy(f, control=list(niter=10,ftol=0.01))
>
> or
>
> o = optimmy(f,control=control(niter=10,ftol=0.01))
>
>  here you are explicitly constructing a 'control' object that has the
> options for controlling the optimiser, and it will have its own
> sensible defaults which the user can selectively override. It seems to
> be the correct paradigm for collecting related parameters, and indeed
> is used in lots of R code.
>
>  Done this way you get selectively overridable arguments, a meaningful
> name, readable code, leveraging the built-in defaults system, and the
> possibility of sticking consistency checks in your control() function.
>
>  Tell me where that is not made of pure win?
>
> Barry
>

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to