From csardi.gabor at gmail.com  Sat Nov  1 02:46:09 2014
From: csardi.gabor at gmail.com (=?UTF-8?B?R8OhYm9yIENzw6FyZGk=?=)
Date: Fri, 31 Oct 2014 21:46:09 -0400
Subject: [Rd] Options that are local to the package that sets them
In-Reply-To: <CAP01uRmKvVjtzbsL+Afn5bXm-uZ50vXHTZZ+yzE4OS1ooiJuuQ@mail.gmail.com>
References: <CABtg=KmCrX1G3K8BxdeJsHvMpMhwoscZ0ExY4_ga9614oYB=KQ@mail.gmail.com>
	<CAP01uR=gS6Zr_QxHjnzCkydRqyZgo2Faoin56ugDoNtPpu4ivA@mail.gmail.com>
	<CABtg=Knpvsx5SSFaDyS+bDmSHpNqXn8Hj2zEWgz1-5UiRd-2bA@mail.gmail.com>
	<CAP01uRmKvVjtzbsL+Afn5bXm-uZ50vXHTZZ+yzE4OS1ooiJuuQ@mail.gmail.com>
Message-ID: <CABtg=K=tDuYRvqNP61-5g8mbapT3tFU8W=u39A+dzYP+2o_rQg@mail.gmail.com>

On Fri, Oct 31, 2014 at 9:20 PM, Gabor Grothendieck
<ggrothendieck at gmail.com> wrote:
[...]
> Isn't your problem really just that you want multiple sets of
> settings?  That's what settings provides.

Almost. Multiple sets of settings, set up by the same package. So
essentially I want pkgA to use different settings when called from
different packages.

E.g. imagine that my package igraph has an option that sets a color
plot plotting. Another package, qgraph sets this setting to something,
say "red". Now another package xgraph wants to set it to "green". What
I want is to use "red" when plotting through qgraph, and to use
"green" when plotting from xgraph.

igraph provides the API for setting this option, so if I just use
'settings' (or a similar technique) in igraph, then xgraph's setting
will overwrite qgraph's setting.

> pkgA would provide a class whose instances are created by the clients.
> Assuming you wrap this in a function create:
>
> inst1 <- create(a = 1, b = 2)
>
> where create sets up a settings object and does anything else
> returning the handle inst1.
>
> When you want to do something you would pass the instance to the
> function or method that actually carries it out.  This could be done
> with any OO system in R without settings but if you are looking for an
> options type interface which I thought you were then you might be able
> to leverage that package.

You are right, this should work. I would like to avoid passing the
settings object to each and every igraph function, though. (Would need
to update 500+ functions.) But that does not seem to be possible,
unless I start messing with the call stack.

G.



[Rd] Options that are local to the package that sets them
=?UTF-8?B?R8OhYm9yIENzw6FyZGk=?=