This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Opening request for debate: the "requires" clause...

2 replies
Quenio dos Santos
Joined: 2009-11-15,
User offline. Last seen 42 years 45 weeks ago.
Hello All,
I am wondering how people few about this, but I am all for the return of the "requires" syntax as an option to define selftypes.
That syntax is much more intuitive when you are implementing system modules as traits and defining the dependencies of those modules using selftypes.
From the Programming in Scala book, where SimpleRecipes uses fruits defined in SimpleFoods, this is how one would define the dependency of SimpleRecipes on SimpleFoods with the selftype syntax in Scala 2.7:
trait SimpleRecipes {    this: SimpleFoods => // expresses the dependency by having SimpleFoods as the selftype
    object FruitSalad extends Recipe("Fruit Salad", List(Apple, Pear)) // Apple and Pear are in scope.     ...}
The syntax above is probably more precise than the "requires" syntax in earlier versions of Scala, but from the context of combining system's modules (which is what SimpleRecipes and SimpleFoods are in this example; they are part of a larger system of Recipes), the "requires" syntax is so much more intuitive:
trait SimpleRecipes requires SimpleFoods {
    object FruitSalad extends Recipe("Fruit Salad", List(Apple, Pear)) 
}
I would love it to come back even if optional.
- Quenio
Dave Griffith
Joined: 2009-01-14,
User offline. Last seen 42 years 45 weeks ago.
Re: Opening request for debate: the "requires" clause...

I strongly advocate the resurrection of the "requires" syntax. Clean,
evocative, precise, giving an exact indication of the normal usage. That it
was yanked due to griping from the JML community (??!?!WTF??!!!?) was a
ridiculous inversion of importance.

--Dave Griffith

Quenio dos Santos
Joined: 2009-11-15,
User offline. Last seen 42 years 45 weeks ago.
Re: Opening request for debate: the "requires" clause...
I was surprised that nobody else picked up on this one. 
It just makes so much sense to me. The "requires" syntax does portray very well one of the main characteristics of this language, which is working on the small and the large.

On Fri, Nov 20, 2009 at 10:11 PM, Dave Griffith <dave [dot] l [dot] griffith [at] gmail [dot] com> wrote:


I strongly advocate the resurrection of the "requires" syntax.  Clean,
evocative, precise, giving an exact indication of the normal usage.  That it
was yanked due to griping from the JML community (??!?!WTF??!!!?) was a
ridiculous inversion of importance.

--Dave Griffith
--
View this message in context: http://old.nabble.com/Opening-request-for-debate%3A-the-%22requires%22-clause...-tp26453515p26453643.html
Sent from the Scala - Debate mailing list archive at Nabble.com.


Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland