[Rd] Define 'in' for new class
gunter.berton at gene.com
Tue Aug 12 16:30:43 CEST 2014
See the 'iterators' package on CRAN.
Genentech Nonclinical Biostatistics
"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
On Tue, Aug 12, 2014 at 12:28 AM, peter dalgaard <pdalgd at gmail.com> wrote:
> On 12 Aug 2014, at 08:29 , Simon Knapp <sleepingwell at gmail.com> wrote:
>> Hi List,
>> Is it possible to define how 'in' works for an object of a specific class
>> (to achieve a similar result to implementing the iterator protocol in a
>> class Python)?
> No, because 'in' doesn't really exist, it is "syntactic sugar" to sweeten a call to the "for" function with its three arguments. E.g.
>  1
>  2
> So what you're really asking for is something like a `for` with class dispatch or the two first arguments replaced by an iterator mechanism. That's not in the cards, at least at the moment, but I suppose it isn't completely out of the question either -- ideas of this sort get bandied around occasionally. It would require changes to R's internals; it is not something you can do in (say) a package.
>> Simon Knapp
>> [[alternative HTML version deleted]]
>> R-devel at r-project.org mailing list
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
> R-devel at r-project.org mailing list
More information about the R-devel