What's New in Scala 2.8: Named and Default Parameters
Summary:
The third installment of a series of articles on the latest Scala release, Scala 2.8, Jon Pretty describes Scala 2.8's support for named and default parameters.
The ability to add new comments in this discussion is temporarily disabled.
Most recent reply: September 29, 2010 0:56 PM by
Valery
|
The third installment of a series of articles on the latest Scala release, Scala 2.8, Jon Pretty describes Scala 2.8's support for named and default parameters. http://www.artima.com/scalazine/articles/named_and_default_parameters_in_scala.htmlWhat do you think of how named and default parameters are done in Scala?
|
|
|
I was always a fan of features that help clarify code, even at the expense of increasing the word count.
Of course, one man's clarity is another man's noise.
Maybe I've spent too much time around IBM mainframes in my past where wordiness is a way of life!
|
|
|
Lou,
For me named parameters both add clarity and reduce noise:
1. As a developer of some API code I prefer to have one method with optional named parameters rather than several overloaded methods that delegates to each other.
2. As a user of some API I would prefer to type two-three short parameter names (or better yet have them all auto-suggested/completed by IDE) rather than select necessary method overload among 5-6 variants or type numerous nulls/zeros/empty-strings "default values" explicitly.
For opponents of named arguments I would suggest the following: a) Try to add a weak-referenced event listener in AS3 via IEventDispatcher.addEventListener b) Try to open a password-protected workbook in MS Excel VBA via Workbooks.Open
P.S. I never developed software for IBM mainframes, but I have some experience with SAP ABAP, so I pretend I may add a word on wordiness :)
|
|