2. Annotated import
● Problem:
– Imports not composable
– Set of implicit variables often configured through
import.
● Solution
– Allow annotations before import statement
– @exported import x._ => export x and all
exported imports inside one.
3. Problem Example:
File A
– import com.mongodb.casbah.Imports._
– import com.novus.salat._
– import com.mycompany.salatcontext._
– …..............
● File B
– import com.mongodb.casbah.Imports._
– import com.novus.salat._
– import com.novus.salat.global._
– ….................
4. Problem Example:
File A
– import com.mongodb.casbah.Imports._
– import com.novus.salat._
– import com.mycompany.salatcontext._
– …..............
● File B
– import com.mongodb.casbah.Imports._
– import com.novus.salat._
– import com.novus.salat.global._
– ….................
5. Proposed Solution
● Allow annotations before import
● @exported import X._
– Members of X
– @exported imports from X:
7. Common usage patterns:
– Application writers:
● encapsulate all external dependencies in one package
object
– Library writers:
● Don't use, provide one module which application
writers will use.
8. Import via inheritance:
X <: Y =>
● should exported imports in X be visible in Y
trait X
{
@exported import something.Interesting
}
trait Y { .. use something.Interesting }
9. Import via inheritance
● PRO
– People actually emulate this approach by defining
aliases for imported methods in traits.
● CONTRA
– Complexity, ... impossible to disable simple.
● (provide own imports instead exported will work)
10. Implementation
● Compiler
– Core, Scaladoc, Tests,
– (new SIP-18 style implicit ?)
● Reflection
– Classfile format
– Symbols/Tree API