R-alpha: options(..) vs. .Options // Re(1i) = 2.4976e-307

Luke Tierney luke@stat.umn.edu
Thu, 22 May 1997 12:10:52 -0500 (CDT)


Martin Maechler wrote:
> 
> The 	.Options
> 
> vector had been introduced a while ago after my suggestion
> (see Ross's E-mail below).
> .Options$digits is used be default in several  print methods (eg print.lm),
> however, deparse(.) e.g., uses options()$width, and not .Options$width.
> 
> Another problem is that  .Options
> is still not in the documentation (on-line help).
> Before one could add it there, we'd need ``the specs''.
> 
> I think the (at least my) idea was that
> 
> 	options(.)  queries or sets elements in the   .Options  list
> 
> and all functions -- including the internal ones -- use  .Options.
> As far as I know, this is what S does.
> Currently, this is NOT the case in R.
> 

If I understand this right (which may be a big if :-)) this is a bit
tricky.  What S is trying to do is make .Options a dynamically scoped
variable. This seems to work fine from the user perspective, i.e. if I
do

	g<-function(x) print(x)
	f<-function(x) { .Options$digits<-3; g(x) }

then I get the "right thing"

> f(888888888)
[1] 8.89e+08
[1] 888888888

but actually writing your own functions that use .Options is tricky --

	g<-function() .Options$digits
	f<-function() { .Options$digits<-3; g() }

produces

> f()
[1] 7
> 

since the reference to .Options is governed by ordinary scoping rules.
So some convenient way of looking up the closest dynamic binding is
needed -- just referencing .Options in print.lm, for example, won't do
it. Current Splus defines several methods for print and summary that
just reference .Options, but unless some internal magic is being used
for this name, they won't work as expected.

luke



-- 
Luke Tierney
University of Minnesota                      Phone:           612-625-7843
School of Statistics                         Fax:             612-624-8868
206 Church Street                            email:      luke@stat.umn.edu
Minneapolis, MN 55455 USA                    WWW:  http://www.stat.umn.edu
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-