addition (juxtaposition) unhelpful for some cases with a clear interpretation
Closed this issue · 1 comments
RobinHankin commented
Look at this:
> a <- rfree(10,3)
> a
[1] c^-2.a^3 a^2.c b^2.c^2.b^-1 a.c^-1 c^5
[6] b^2.c^3.b c^3.a^-4 c^3.b^4 b^-2.a^3.b^-1 a^-2.c^-1.b^3
> a+'z'
Error in Ops.free(a, "z") : <free> + <non-free> is not defined
> a+as.free('z')
[1] c^-2.a^3.z a^2.c.z b^2.c^2.b^-1.z a.c^-1.z
[5] c^5.z b^2.c^3.b.z c^3.a^-4.z c^3.b^4.z
[9] b^-2.a^3.b^-1.z a^-2.c^-1.b^3.z
>
In the above, a+'z'
has a natural interpretation but this is not accepted. One has to coerce as in the second addition to make it work. I guess something like 'z'+a
would also have a natural interpretation but this idiom would require S4
methods to work.
RobinHankin commented
I do not think this should be fixed. It is reasonable to force the user to coerce the second addend to a freegroup
object.