Recently I was watching Automatic dependency injection in pure scala 3, and during the video, the speaker has to make a pause to basically describe the quirks of typing for comprehension in a IDE, where you’d typically type for {
and the IDE will auto complete the other bracket, and this is invalid scala syntax. The author then goes on to explain that he adds a yield ()
to cope for a bit so that he can start writing the generators section.
I’ve been doing scala for close to 15 years now and this is definitely an issue I experience daily.
Every new members to projects who are new to scala, I have to explain to them this quirk so that the IDE doesn’t yell at them with incomprehensible errors product of the syntax not being complete.
The way the compiler interprets the syntax, essentially forces you to write in a spirally way, where you start in say line 1, move to 3, so that you can finally work on line 2, where you actually start writing the generators which is the part you care about.
I don’t have a solution to this, but this has been annoying me, my students, and everyone that watches a live scala coding session for ages now. Hopefully there’s something that could be done about it.