Prefix methods? #17807
Replies: 3 comments
-
I think this would be too ambiguous. The parser is supposed to resolve these things, but now how things eventually parse would have to be based on type checking info? Seems hardly doable in a clean way. Also, trying to parse |
Beta Was this translation helpful? Give feedback.
-
I think Scala is moving away from this level of syntactic flexibility, rather than moving towards it. (Consider the elimination of postfix syntax and the restriction of infix syntax to methods that specifically declared infix.) |
Beta Was this translation helpful? Give feedback.
-
I miss postfix, and I think with Scala 3 it could be robust again. Maybe also prefix! Let's not be cowards! That is, forwards or backwards, but wards the cow? I mean I like the cow that showed up in La Brea. |
Beta Was this translation helpful? Give feedback.
-
We already have infix methods and we have limited unary operators, I think an option for prefix methods would allow for more expressivity, allowing some methods to behave like keywords and allowing more unary operators.
Use cases:
I don't know if those should be defined as instance methods or as parametrized methods.
One problem I see with this is differentiating between
If the implementation would be instance methods, a check for whether the first term name
f
is in scope, if it's in scope then find memberf
ofg x
if it's not try looking at memberg
off
Beta Was this translation helpful? Give feedback.
All reactions