Subject: Re: [R] nargs() inside "[.myclass"
From: Peter Dalgaard BSA (p.dalgaard@biostat.ku.dk)
Date: Tue 27 Jun 2000 - 08:35:57 EST
Message-ID: <x28zvst6ia.fsf@blueberry.kubism.ku.dk>
"Vadim Kutsyy" <vadim@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@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@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
This archive was generated by hypermail 2b25 : Mon 17 Jul 2000 - 12:33:24 EST