SlideShare a Scribd company logo
1 of 14
Annotated import


●   SIP - ???

●   http://bit.ly/TLZYKb
https://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:
    ●   Don't 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

More Related Content

Similar to Annotated imports

Similar to Annotated imports (20)

Scala laboratory. Globus. iteration #1
Scala laboratory. Globus. iteration #1Scala laboratory. Globus. iteration #1
Scala laboratory. Globus. iteration #1
 
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides:  Let's build macOS CLI Utilities using SwiftMobileConf 2021 Slides:  Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
 
Why scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with thisWhy scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with this
 
Go at Skroutz
Go at SkroutzGo at Skroutz
Go at Skroutz
 
OpenCms Days 2015 Workflow using Docker and Jenkins
OpenCms Days 2015 Workflow using Docker and JenkinsOpenCms Days 2015 Workflow using Docker and Jenkins
OpenCms Days 2015 Workflow using Docker and Jenkins
 
Sep Nasiri "Upwork PHP Architecture"
Sep Nasiri "Upwork PHP Architecture"Sep Nasiri "Upwork PHP Architecture"
Sep Nasiri "Upwork PHP Architecture"
 
Iteria lowcode 2022-01-10
Iteria lowcode 2022-01-10Iteria lowcode 2022-01-10
Iteria lowcode 2022-01-10
 
My "Perfect" Toolchain Setup for Grails Projects
My "Perfect" Toolchain Setup for Grails ProjectsMy "Perfect" Toolchain Setup for Grails Projects
My "Perfect" Toolchain Setup for Grails Projects
 
JavaScript Modules Past, Present and Future
JavaScript Modules Past, Present and FutureJavaScript Modules Past, Present and Future
JavaScript Modules Past, Present and Future
 
1 session installation
1 session installation1 session installation
1 session installation
 
Sample Project using design patterns and agile
Sample Project using design patterns and agileSample Project using design patterns and agile
Sample Project using design patterns and agile
 
Create ReactJS Component & publish as npm package
Create ReactJS Component & publish as npm packageCreate ReactJS Component & publish as npm package
Create ReactJS Component & publish as npm package
 
Get to Know AtoM's Codebase
Get to Know AtoM's CodebaseGet to Know AtoM's Codebase
Get to Know AtoM's Codebase
 
Balisage - EXPath Packaging
Balisage - EXPath PackagingBalisage - EXPath Packaging
Balisage - EXPath Packaging
 
Not Your Fathers C - C Application Development In 2016
Not Your Fathers C - C Application Development In 2016Not Your Fathers C - C Application Development In 2016
Not Your Fathers C - C Application Development In 2016
 
[scala.by] Launching new application fast
[scala.by] Launching new application fast[scala.by] Launching new application fast
[scala.by] Launching new application fast
 
[Patel] SPFx: An ISV Insight into latest Microsoft's customization model
[Patel] SPFx: An ISV Insight into latest Microsoft's customization model[Patel] SPFx: An ISV Insight into latest Microsoft's customization model
[Patel] SPFx: An ISV Insight into latest Microsoft's customization model
 
Dart the better Javascript 2015
Dart the better Javascript 2015Dart the better Javascript 2015
Dart the better Javascript 2015
 
R programming for data science
R programming for data scienceR programming for data science
R programming for data science
 
Dart the Better JavaScript
Dart the Better JavaScriptDart the Better JavaScript
Dart the Better JavaScript
 

More from Ruslan Shevchenko

Jslab rssh: JS as language platform
Jslab rssh:  JS as language platformJslab rssh:  JS as language platform
Jslab rssh: JS as language platform
Ruslan Shevchenko
 

More from Ruslan Shevchenko (20)

Embedding Generic Monadic Transformer into Scala. [Tfp2022]
Embedding Generic Monadic Transformer into Scala. [Tfp2022]Embedding Generic Monadic Transformer into Scala. [Tfp2022]
Embedding Generic Monadic Transformer into Scala. [Tfp2022]
 
Svitla talks 2021_03_25
Svitla talks 2021_03_25Svitla talks 2021_03_25
Svitla talks 2021_03_25
 
Akka / Lts behavior
Akka / Lts behaviorAkka / Lts behavior
Akka / Lts behavior
 
Papers We Love / Kyiv : PAXOS (and little about other consensuses )
Papers We Love / Kyiv :  PAXOS (and little about other consensuses )Papers We Love / Kyiv :  PAXOS (and little about other consensuses )
Papers We Love / Kyiv : PAXOS (and little about other consensuses )
 
Scala / Technology evolution
Scala  / Technology evolutionScala  / Technology evolution
Scala / Technology evolution
 
{co/contr} variance from LSP
{co/contr} variance  from LSP{co/contr} variance  from LSP
{co/contr} variance from LSP
 
N flavors of streaming
N flavors of streamingN flavors of streaming
N flavors of streaming
 
Scala-Gopher: CSP-style programming techniques with idiomatic Scala.
Scala-Gopher: CSP-style programming techniques with idiomatic Scala.Scala-Gopher: CSP-style programming techniques with idiomatic Scala.
Scala-Gopher: CSP-style programming techniques with idiomatic Scala.
 
SE 20016 - programming languages landscape.
SE 20016 - programming languages landscape.SE 20016 - programming languages landscape.
SE 20016 - programming languages landscape.
 
Few simple-type-tricks in scala
Few simple-type-tricks in scalaFew simple-type-tricks in scala
Few simple-type-tricks in scala
 
Scala jargon cheatsheet
Scala jargon cheatsheetScala jargon cheatsheet
Scala jargon cheatsheet
 
Java & low latency applications
Java & low latency applicationsJava & low latency applications
Java & low latency applications
 
Csp scala wixmeetup2016
Csp scala wixmeetup2016Csp scala wixmeetup2016
Csp scala wixmeetup2016
 
IDLs
IDLsIDLs
IDLs
 
R ext world/ useR! Kiev
R ext world/ useR!  KievR ext world/ useR!  Kiev
R ext world/ useR! Kiev
 
Jslab rssh: JS as language platform
Jslab rssh:  JS as language platformJslab rssh:  JS as language platform
Jslab rssh: JS as language platform
 
Behind OOD: domain modelling in post-OO world.
Behind OOD:  domain modelling in post-OO world.Behind OOD:  domain modelling in post-OO world.
Behind OOD: domain modelling in post-OO world.
 
scala-gopher: async implementation of CSP for scala
scala-gopher:  async implementation of CSP  for  scalascala-gopher:  async implementation of CSP  for  scala
scala-gopher: async implementation of CSP for scala
 
Programming Languages: some news for the last N years
Programming Languages: some news for the last N yearsProgramming Languages: some news for the last N years
Programming Languages: some news for the last N years
 
JDays Lviv 2014: Java8 vs Scala: Difference points & innovation stream
JDays Lviv 2014:  Java8 vs Scala:  Difference points & innovation streamJDays Lviv 2014:  Java8 vs Scala:  Difference points & innovation stream
JDays Lviv 2014: Java8 vs Scala: Difference points & innovation stream
 

Recently uploaded

Recently uploaded (20)

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

Annotated imports

  • 1. Annotated import ● SIP - ??? ● http://bit.ly/TLZYKb https://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: ● 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
  • 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