[SOLVED] Difference between where {T} and where T and infix operators


Hello !
[english is not my native language. So if you don’t understand, tell me, I’ll try to say otherwise]
First, thanks to all Julia’s developpers. I discovered this language yesterday, and I find it really nice !

Second, I’m reading the doc, and have beginner questions,

  • Is there a difference between same_type(x::T,y::T) where T = true and same_type(x::T,y::T) where {T} = true ? I tried both and it seems to me that they work same.
  • Does there exist in Julia user-defined infix operators ?

Thanks ! :slight_smile:




With just one type var, the two are identical. The curly braces are a convenient shorthand when you have more than one variable — it’s just where {T,S} instead of where S where T.

It also makes it a bit easier for me to read where {T} = ... since otherwise my brain wants to make it seem like you’re assigning the function body to just T.

(Also your English is great)



Oh and as to your second question, there’s a limited number of names that can be used as infix operators, but all of them can be used for your own purposes. See https://docs.julialang.org/en/v1/manual/mathematical-operations/#Operator-Precedence-and-Associativity-1 (and the link to parser.scm) for the list and precedences.



Thanks for your quick replies !

So, its not possible to have user-defined infix operator symbol ? :frowning: Hm, this programming language can’t be perfect-like :slight_smile:

If I have other questions, at a moment, should I open another topic ? Or write them down here ?



You can’t invent your own symbols entirely, but you can choose from a long list of existing unicode symbols — check the parser.scm link. Most of these have no existing operator meaning.



It’s better to open a new topic for a new question. That helps keep the conversations clearer and easier to read for future users.

1 Like


oh ! I havn’t seen the link to parser.csm (sorry mbauman). thanks :slight_smile:

And, ok rdeits, i’ll do so !

Thanks for your replies to you !