Annotated import●   SIP - ???●   http://bit.ly/TLZYKbhttps://github.com/rssh/scala-annotated-import-example●
Annotated import●   Problem:    –   Imports not composable    –   Set of implicit variables often configured through      ...
Problem Example:    File A    –   import com.mongodb.casbah.Imports._    –   import com.novus.salat._    –   import com.my...
Problem Example:    File A    –   import com.mongodb.casbah.Imports._    –   import com.novus.salat._    –   import com.my...
Proposed Solution●   Allow annotations before import●   @exported import X._    –   Members of X    –   @exported imports ...
Application module config:package object my.app{–   @exported import all.required.libraries–   @exported import language._...
Common usage patterns:–   Application writers:    ●   encapsulate all external dependencies in one package        object– ...
Import via inheritance:X <: Y      =>  ●   should exported imports in X be visible in Y      trait X      {          @expo...
Import via inheritance●   PRO    –   People actually emulate this approach by defining        aliases for imported methods...
Implementation●   Compiler    –   Core, Scaladoc, Tests,    –   (new SIP-18 style implicit ?)●   Reflection    –   Classfi...
Implementation●   https://github.com/rssh/scala    –   Branch annotated-import●   https://github.com/rssh/scala-annotated-...
What needed:●   Pre-SIP review    –   http://bit.ly/TLZYKb●   Examples of usage    –   (just fork scala-import-annotations...
Related things●   @deprecated import ....    –   (add warning, should not be hard)●   @generated(generator) import    –   ...
Thanks●   Ruslan Shevchenko    –   https://github.com/rssh/    –   ruslan@shevchenko.kiev.ua    –   @rssh1
Upcoming SlideShare
Loading in …5
×

Annotated imports

330 views

Published on

pre-sip about adding 'annotated imports' feature to scala language.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
330
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Annotated imports

  1. 1. Annotated import● SIP - ???● http://bit.ly/TLZYKbhttps://github.com/rssh/scala-annotated-import-example●
  2. 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. 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. 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. 5. Proposed Solution● Allow annotations before import● @exported import X._ – Members of X – @exported imports from X:
  6. 6. Application module config:package object my.app{– @exported import all.required.libraries– @exported import language._– // disable some annotations– class unchecked extends Annotation {}}
  7. 7. Common usage patterns:– Application writers: ● encapsulate all external dependencies in one package object– Library writers: ● Dont use, provide one module which application writers will use.
  8. 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. 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. 10. Implementation● Compiler – Core, Scaladoc, Tests, – (new SIP-18 style implicit ?)● Reflection – Classfile format – Symbols/Tree API
  11. 11. Implementation● https://github.com/rssh/scala – Branch annotated-import● https://github.com/rssh/scala-annotated-import-exa (scala-annotated-import-example)● State – Core : mostly done – Scaladoc: in progress
  12. 12. What needed:● Pre-SIP review – http://bit.ly/TLZYKb● Examples of usage – (just fork scala-import-annotations-example)● Welcome to hack.
  13. 13. Related things● @deprecated import .... – (add warning, should not be hard)● @generated(generator) import – Macros API ?
  14. 14. Thanks● Ruslan Shevchenko – https://github.com/rssh/ – ruslan@shevchenko.kiev.ua – @rssh1

×