Julia does not allow user-defined operators. There are just a lot of
pre-defined operators. We could add ++ as an operator, but we'd have to
decide how it parses and what it's precedence is. In Haskell it's an infix
operator used for concatenation. In C it's a prefix and postfix operator
that increments things. So there's no single obvious way to parse it.


On Mon, Jul 21, 2014 at 4:41 PM, Hans W Borchers <hwborch...@gmail.com>
wrote:

> > It is not, look at julia-parser.scm for the list of operators you are
> able to define.
>
> And I thought Julia allows to define operators as users like.
> Is there a special reason (inconsistency) why ++ would not not be allowed
> while // is?
> Could this be changed by an appropriate entry in julia-parser.scm (or
> somewhere else)?
>
>
>
> On Tuesday, July 22, 2014 12:06:30 AM UTC+2, Jake Bolewski wrote:
>>
>> It is not, look at julia-parser.scm for the list of operators you are
>> able to define.
>>
>> On Monday, July 21, 2014 5:57:41 PM UTC-4, Steve Kelly wrote:
>>>
>>> I think the issue is that ++ is not an operator in julia.
>>>
>>>
>>> On Mon, Jul 21, 2014 at 5:51 PM, Hans W Borchers <hwbor...@gmail.com>
>>> wrote:
>>>
>>>> I was interested to define "++" as operator for concatenating strings.
>>>> I can define "+" for this purpose, but for "++" I get
>>>>
>>>>     julia> function ++(x::String, y::String)
>>>>                x * y
>>>>            end
>>>>     ERROR: syntax: expected "(" in "function" definition
>>>>
>>>> I looked up "//" in Rational.jl, but did not see the difference in how
>>>> to define this operation.
>>>>
>>>
>>>

Reply via email to