Scala 3是否有特定的标准库,还是只是继承自Scala 2?

huangapple go评论57阅读模式
英文:

Is there a Scala 3 specific standard library or is it just inherited from Scala 2?

问题

Scala 3是否使用了Scala 2标准库中的所有集合?(Scala的“标准库”包括哪些元素?)

Scala 3是否有特定的“标准库”?

是否有计划将Scala 2库重新实现为Scala 3?

我在寻找Scala 3中的不可变列表的实现,但我意识到dotty存储库中似乎没有这样的东西。

我原本希望在dotty存储库中找到Scala 2列表的实现

英文:

Is it the case that Scala 3 uses all the collections from Scala 2 standard library? (What elements Scala "standard library" consists of?)

Is there any Scala 3 specific "standard library"?

Are there plans to reimplement Scala 2 libraries to Scala 3?

I was looking for an implementation of an immutable list in Scala 3 and I realized that there seems to be no such thing in the dotty repo.

I was expecting to find an implementation of Scala 2 list in the dotty repo as well.

答案1

得分: 4

标准库在 Scala 3 和 Scala 2.13 之间共享,并作为 Scala 2.13 的一部分进行维护。

标准库经过重构/重新设计,仅使用同时存在于 Scala 2.13 和 Scala 3 中的语言特性。

(注:当我提到“Scala 3”和“Scala 2.13”时,我指的是具有这些版本号的实现。Scala 语言规范并未说明标准库的实现方式。)

英文:

The standard library is shared between Scala 3 and Scala 2.13 and is maintained as part of Scala 2.13.

The standard library was refactored / re-engineered such that it only uses language features that exist in both Scala 2.13 and Scala 3.

(Note: when I write "Scala 3" and "Scala 2.13", I mean the implementations with those version numbers. The Scala Language Specification does not say anything about how the standard library is implemented.)

答案2

得分: 2

Scala 2.13标准库是Scala 3标准库的一部分

"org.scala-lang" % "scala-library" % "2.13.10"

https://mvnrepository.com/artifact/org.scala-lang/scala-library

https://search.maven.org/artifact/org.scala-lang/scala-library/2.13.10/jar

https://github.com/scala/scala/tree/2.13.x/src/library/scala

标准库

一个值得注意的例子是Scala 2.13库。我们确实决定了
Scala 2.13库是Scala 3的官方标准库。

值得注意的是标准库是由构建工具自动提供的,不需要手动配置。

https://docs.scala-lang.org/scala3/guides/migration/compatibility-classpath.html#the-standard-library

但Scala 3标准库还包括Scala 3特定的部分(包括scala.derivingscala.compiletimescala.quotedscala.reflectscala.runtimescala.utilscala.annotation

"org.scala-lang" % "scala3-library_3" % "3.2.2"

或者

"org.scala-lang" %% "scala3-library" % "3.2.2"

https://mvnrepository.com/artifact/org.scala-lang/scala3-library

https://search.maven.org/artifact/org.scala-lang/scala3-library_3/3.2.2/jar

https://github.com/lampepfl/dotty/tree/main/library/src/scala

英文:

Scala 2.13 standard library is a part of Scala 3 standard library

"org.scala-lang" % "scala-library" % "2.13.10"

https://mvnrepository.com/artifact/org.scala-lang/scala-library

https://search.maven.org/artifact/org.scala-lang/scala-library/2.13.10/jar

https://github.com/scala/scala/tree/2.13.x/src/library/scala

> The Standard Library
>
> One notable example is the Scala 2.13 library. We have indeed decided
> that the Scala 2.13 library is the official standard library for Scala
> 3.
>
> Let’s note that the standard library is automatically provided by the
> build tool, you should not need to configure it manually.

https://docs.scala-lang.org/scala3/guides/migration/compatibility-classpath.html#the-standard-library

But there is also additional Scala 3 specific part of Scala 3 standard library (packages scala.deriving, scala.compiletime, scala.quoted, scala.reflect, scala.runtime, scala.util, scala.annotation)

"org.scala-lang" % "scala3-library_3" % "3.2.2"

or

"org.scala-lang" %% "scala3-library" % "3.2.2"

https://mvnrepository.com/artifact/org.scala-lang/scala3-library

https://search.maven.org/artifact/org.scala-lang/scala3-library_3/3.2.2/jar

https://github.com/lampepfl/dotty/tree/main/library/src/scala

huangapple
  • 本文由 发表于 2023年2月19日 22:51:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/75500964.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定