Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question: should infix notation be used for non-symbolic method names? #53

Open
SethTisue opened this issue Jun 18, 2018 · 3 comments
Open

Comments

@SethTisue
Copy link

I have mixed feelings (leaning towards negative) about the extensive use of infix notation in the book for code like:

circle(10) beside square(20) beside square(30)

my impression is that the Scala community experimented with this style pretty heavily for a long time, but in recent years almost everyone has retreated from it and it's not really a mainstream style anymore for ordinary, alphanumerically-named methods like beside

but my concern isn't only about what the dominant style is in the community, it's also about what an appropriate style for getting started with the language is. for years now, I've seen (on Gitter and IRC, primarily) beginners tripping themselves up with what this syntax means and how it is parsed. beginners end up using a mishmash of spaces and dots and parens and not really knowing what's going on and where infix is permitted and when it isn't and when you need parens to make it work and when you don't. it seems like a distraction to me. by sticking with a.b(c) style you bypass all these issues, freeing up mental energy to focus on more important things

would a PR changing the code to consistently use this style instead:

circle(10).beside(square(20)).beside(square(30))

be welcome...?

@SethTisue
Copy link
Author

(we're at ScalaBridge Montreal right now, @ironfish had the same reaction, that this syntax shouldn't be used to start with, or if it is used, should at least be explained as being equivalent to normal method call syntax)

@noelwelsh
Copy link
Contributor

noelwelsh commented Oct 22, 2018

Yeah, I agree. I realised last time I was teaching @ ScalaBridge that it doesn't bring any benefit to introduce this syntax early.

@SethTisue
Copy link
Author

Scala 3 discourages the infix style, so this change would pave the way towards eventually moving to Scala 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants