On Tue, Jun 16, 2015 at 8:24 PM, Herv? Pag?s <hpages at fredhutch.org> wrote: [...]> > If I was to override `+` to concatenate strings, I would make it stick > to the recycling scheme used by arithmetic and comparison operators > (which is the most sensible of all IMO).Yeah, I agree, paste's recycling rules are sometimes painful. This could be "fixed" with a nice new '+' concatenation operator, too. :) Gabor> H.[...]
One of the poster's on the SO post I linked to previously suggested this but if '+' were made to be S4 compliant, then adding the ability to concat strings with '+' would be a relatively simple addition (no pun intended) to the code base I believe. With a lot of other languages supporting this kind of concatenation, this is what surprised me most when first learning R. This is where my (lack of) experience in R starts to show and why I brought up the question about performance. I'm wondering how bad performance would be effected by making '+' (or all arithmetic operators in general) S4 compliant. Josh Bradley On Tue, Jun 16, 2015 at 8:35 PM, G?bor Cs?rdi <csardi.gabor at gmail.com> wrote:> On Tue, Jun 16, 2015 at 8:24 PM, Herv? Pag?s <hpages at fredhutch.org> wrote: > [...] > > > > If I was to override `+` to concatenate strings, I would make it stick > > to the recycling scheme used by arithmetic and comparison operators > > (which is the most sensible of all IMO). > > Yeah, I agree, paste's recycling rules are sometimes painful. This > could be "fixed" with a nice new '+' concatenation operator, too. :) > > Gabor > > > H. > > [...] >[[alternative HTML version deleted]]
On Tue, Jun 16, 2015 at 10:30 PM, Joshua Bradley <jgbradley1 at gmail.com> wrote:> One of the poster's on the SO post I linked to previously suggested this but > if '+' were made to be S4 compliant, then adding the ability to concat > strings with '+' would be a relatively simple addition (no pun intended) to > the code base I believe. With a lot of other languages supporting this kind > of concatenation, this is what surprised me most when first learning R. > > This is where my (lack of) experience in R starts to show and why I brought > up the question about performance. I'm wondering how bad performance would > be effected by making '+' (or all arithmetic operators in general) S4 > compliant.I don't know much about S4, but '+' is already generic, so implementation would be easy I guess. Also, since it is already generic, I don't think this would affect performance at all. (But FIXME please.) The reason why it is not implemented is not because it is difficult. Gabor> Josh Bradley
Just to clarify, primitive (C-level) generics do not support dispatch on basic classes (like character). This is for performance (no need to consider dispatch on non-objects) and for sanity (in general, redefining fundamental behaviors is dangerous). It is of course possible to define a "+" method with a signature containing a class not in the set of basic classes. On Tue, Jun 16, 2015 at 7:30 PM, Joshua Bradley <jgbradley1 at gmail.com> wrote:> One of the poster's on the SO post I linked to previously suggested this > but if '+' were made to be S4 compliant, then adding the ability to concat > strings with '+' would be a relatively simple addition (no pun intended) to > the code base I believe. With a lot of other languages supporting this kind > of concatenation, this is what surprised me most when first learning R. > > This is where my (lack of) experience in R starts to show and why I brought > up the question about performance. I'm wondering how bad performance would > be effected by making '+' (or all arithmetic operators in general) S4 > compliant. > > Josh Bradley > > On Tue, Jun 16, 2015 at 8:35 PM, G?bor Cs?rdi <csardi.gabor at gmail.com> > wrote: > >> On Tue, Jun 16, 2015 at 8:24 PM, Herv? Pag?s <hpages at fredhutch.org> wrote: >> [...] >> > >> > If I was to override `+` to concatenate strings, I would make it stick >> > to the recycling scheme used by arithmetic and comparison operators >> > (which is the most sensible of all IMO). >> >> Yeah, I agree, paste's recycling rules are sometimes painful. This >> could be "fixed" with a nice new '+' concatenation operator, too. :) >> >> Gabor >> >> > H. >> >> [...] >> > > [[alternative HTML version deleted]] > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel