Your SlideShare is downloading. ×
Annotated imports
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Annotated imports

143
views

Published on

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

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
143
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Annotated import● SIP - ???● http://bit.ly/TLZYKbhttps://github.com/rssh/scala-annotated-import-example●
  • 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:
  • 6. Application module config:package object my.app{– @exported import all.required.libraries– @exported import language._– // disable some annotations– class unchecked extends Annotation {}}
  • 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. 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
  • 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. What needed:● Pre-SIP review – http://bit.ly/TLZYKb● Examples of usage – (just fork scala-import-annotations-example)● Welcome to hack.
  • 13. Related things● @deprecated import .... – (add warning, should not be hard)● @generated(generator) import – Macros API ?
  • 14. Thanks● Ruslan Shevchenko – https://github.com/rssh/ – ruslan@shevchenko.kiev.ua – @rssh1