[R] nargs() inside "[.myclass"
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Tue Jun 27 00:35:57 CEST 2000
"Vadim Kutsyy" <vadim at kutsyy.com> writes:
> > This does seem to work:
> >
> > > "[.myclass"<-function(x,...)
> > > {n<-nargs();if(n==2&&missing(..1))n<-1;print(n-1)}
> > > x[]
> > [1] 0
> > > x[1]
> > [1] 1
> > > x[1,2]
> > [1] 2
>
>
> It does, thank you. could you explain what ..1 stands for?
It's the first of the "..." arguments.
Some of the things that surround the handling of those are barely
understood by the maintainers. I've certainly been surprised by having
"..1" pop up in match.call() output once in a while. I'm not convinced
that the [] case isn't a bug.
We seem to have managed to code the entire base library without
referring to ..n arguments a single time, but your example looks like
it requires it, unless the current behavior is a bug.
Apropos: Here's a little exercise:
> f<-function(...)nargs()
> f(1)
[1] 1
> f()
[1] 0
> f(,)
[1] 2
> f(,,)
[1] 3
Now, how do you call f with exactly *one* missing argument?
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list