How Scala 3 Givens Work with Scala 2 Implicits

Поділитися
Вставка
  • Опубліковано 8 січ 2025

КОМЕНТАРІ • 12

  • @bomenderick9468
    @bomenderick9468 Рік тому +1

    Amazing how you make these implicitly abstract scala concepts looks explicitly concrete.
    Just enjoy your way of simplifying things.

  • @JasonYeo
    @JasonYeo 3 роки тому +2

    So why did the Scala team introduce givens and usings? How does that improve the implicits situation? The given resolution order is the same as before and now it seems like these are just new keywords for the an old concept. It's basically putting old wine in new bottles.

    • @BloodnutXcom
      @BloodnutXcom 3 роки тому +1

      Implicit keyword becomes deprecated. Scala 3.0 is still backwards compatible but later implicit will be removed.

    • @-Wessel
      @-Wessel 3 роки тому +1

      I think the reason is the name implicit was confusing because:
      - The name does not imply what it does
      - the implicit keyword is used for different things that are completely seperate from each other.
      The new keyword names adress these 2 things. I guess it's like a refactoring of the language: Same functionality but more comprehensible syntax.

  • @BloodnutXcom
    @BloodnutXcom 3 роки тому +4

    tldr: givens+using are interchangable with implicit

    • @rockthejvm
      @rockthejvm  3 роки тому

      Pretty much - with a bit of background about how the compiler works with them

  • @sergeydev8273
    @sergeydev8273 3 роки тому +3

    Like, then watching :)

  • @Nebulorum
    @Nebulorum 3 роки тому +1

    Are there differences between given and implícits, or are they just an alias of each other?

    • @jimaaman
      @jimaaman 3 роки тому +1

      I too am wondering this. Are there compiler optimizations or some other benefit to using/given besides constraining the application of implicits?

    • @rockthejvm
      @rockthejvm  3 роки тому +3

      Givens are not aliases of implicits. They have a different mechanism, it's only how the compiler looks for such values that's the same (so they can work interchangeably). The goal of using/given was indeed to constrain the power of implicits, because they were often misused.

  • @miloventimiglia8547
    @miloventimiglia8547 3 роки тому +1

    Nice!!!:)