You are probably right. I don’t know enough about ::Colon and parser restrictions (.. could clash with the broadcast operator . somehow?), but the following variations seem to work
(&)(pre::Union{String,Ci},next_::String)=return Ci(pre,next_)
@show "a"&"b"
@show "a"&"b"&"c"
(..)(x::Vararg{String})=begin
pre=x[1]
for next_ in x[2:end]
pre=Ci(pre,next_)
end
return pre
end
@show ..("a","b")
@show ..("a","b","c")
yielding
"a" & "b" = Ci("a", "b")
("a" & "b") & "c" = Ci(Ci("a", "b"), "c")
"a" .. "b" = Ci("a", "b")
..("a", "b", "c") = Ci(Ci("a", "b"), "c")
Ci(Ci("a", "b"), "c")
Edit: switching the operators doesn’t work in both cases…
(..)(pre::Union{String,Ci},next_::String)=return Ci(pre,next_)
@show "a".."b"
@show "a".."b".."c"
fails with
ERROR: syntax: ".." is not a unary operator
and
(&)(x::Vararg{String})=begin
pre=x[1]
for next_ in x[2:end]
pre=Ci(pre,next_)
end
return pre
end
@show "a"&"b"
@show "a"&"b"&"c"
fails with
ERROR: MethodError: no method matching &(::Ci, ::String)