Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Programming Scala: procedure syntax dropped in Scala 3

 
Sheriff
Posts: 16940
286
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dean,

I just noticed today that procedure syntax has been dropped from Scala 3 although the old syntax is still supported with an option - see https://dotty.epfl.ch/docs/reference/dropped-features/procedure-syntax.html

Looking through the book code examples, they all seem to be using the new recommended syntax. The stated reason for dropping this and some other constructs is to simplify the language and its implementation. Do you think there were other problems with the procedure syntax that got it on the chopping block?
 
Author
Posts: 23
8
Mac OS X Scala Monad
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It could cause surprises. If you didn't put a return type on the method signature and you forgot the "=", it would infer `Unit` as the return type, even if the body ends with a non-Unit expression. You would probably find that error eventually, but it's annoying and the compilation errors could be mystifying, since the bug is a single missing character, "=".

For me, procedure syntax was a good example of a well-intentioned "convenience" that caused more harm than good, because you don't need a special syntax (you can write `def foo(...):Unit = {...}` to do the same thing) and having this syntax 1) was yet another way to do things instead of having one way to do them and 2) it caused surprises.

So you're right, this is one of several simplifications to the language with several benefits. Here's the full list of dropped features: https://dotty.epfl.ch/docs/Dropped%20Features/index.html

-- Dean
 
Junilu Lacar
Sheriff
Posts: 16940
286
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your insights, Dean. The functional syntax will certainly have a more familiar feel for JavaScript programmers.
 
Could you hold this kitten for a sec? I need to adjust this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic