• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Annotated imports
 

Annotated imports

on

  • 305 views

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

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

Statistics

Views

Total Views
305
Views on SlideShare
305
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

CC Attribution License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Annotated imports Annotated imports Presentation Transcript

    • 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 import.● Solution – Allow annotations before import statement – @exported import x._ => export x and all exported imports inside one.
    • 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._ – ….................
    • 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._ – ….................
    • Proposed Solution● Allow annotations before import● @exported import X._ – Members of X – @exported imports from X:
    • Application module config:package object my.app{– @exported import all.required.libraries– @exported import language._– // disable some annotations– class unchecked extends Annotation {}}
    • 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.
    • 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 }
    • 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)
    • Implementation● Compiler – Core, Scaladoc, Tests, – (new SIP-18 style implicit ?)● Reflection – Classfile format – Symbols/Tree API
    • 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
    • What needed:● Pre-SIP review – http://bit.ly/TLZYKb● Examples of usage – (just fork scala-import-annotations-example)● Welcome to hack.
    • Related things● @deprecated import .... – (add warning, should not be hard)● @generated(generator) import – Macros API ?
    • Thanks● Ruslan Shevchenko – https://github.com/rssh/ – ruslan@shevchenko.kiev.ua – @rssh1