This is a naive question, but given the widespread use of the object.method
notation in OOP languages, I struggle to find a sound reason as of why it can’t (or shouldn’t) be supported in Julia? I assumes this has something to do with code parsing, but what?
Consider the following:
- dot notation to access variable’s property is already well established (in a similar fashion as in C), using
foo.bar
- this is just a sugar syntax that does
method(object, otherargs...)
… but really helpful to chain calls, discover code, and think about the code (the latter is admittedly subjective) - Getting this notation to assign the left hand side of the dot to the first argument of the method seems quite arbitrary … but so is the
do ... end
block - there is not risk of clash with the classical broadcasting dot notation for regular functions, for in this usual case, the dot is between the function’s name and a left parens
- There is no risk of clashing with the classical broadcasting dot notation for operators either, because colon is required when calling it from e.g.
Base.:+
, while broadcasting isn’t. In a similar fashion, usingvariable.function
would just requires operators to be preceded by a colon, as infoo.:+(bar)
- I don’t see any potential breaking change than would require a hypothetical Julia2.0
I feel I’m missing a simple yet not obvious to me case that would prevent this notation to be properly parsed and interpreted.
Or else, it is not supported because of other-than-parsing reasons? (and other than manpower)
… and if not … then wouldn’t it be great to have it available in Julia?