scala.mobile 应该完成什么任务?

发布于 2024-11-02 22:33:48 字数 581 浏览 5 评论 0原文

...以及为什么有 这个误导性的名称(我以为它与 JavaME 或移动/智能手机有关)?

我在互联网上没有找到任何关于 scala.mobile.Code 或 scala.mobile.Location 的参考资料 根本,我也没有设法做任何事情这些类除了获取 ClassCastExcetionNoSuchMethodError 之外。

实际上,Scala 的测试树中甚至没有针对 scala.mobile 的单个测试可以帮助理解该代码。

这些类确实闻起来像是很久以前就被遗忘在源代码树中,并且从那时起就被意外释放了。

也许我只是错过了一些关于他们的事情?

更新: scala.mobile 在 Scala 2.9 中被删除。

...and why has the package this misleading name (I assumed it had something to do with JavaME or mobile/smart phones)?

I found no references on the internet about scala.mobile.Code or scala.mobile.Location at all nor did I manage to do anything with those classes except getting ClassCastExcetions or NoSuchMethodErrors.

Actually there is not even a single test against scala.mobile in the Scala's test tree which could help understanding that code.

The classes really smell like they were forgotten in the source tree a long time ago and got accidentally released since that.

Maybe I just missed something about them?

Update:
scala.mobile was removed in Scala 2.9.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

任性一次 2024-11-09 22:33:48

我刚刚检查了源代码。

几年前,当 Scala 更改类文件的名称修改时,人们似乎忘记了相应地更新这些类。

所以我的答案是:

至少 Location没有 目的,因为不可能从中得到任何有意义的东西(例外情况除外)和 CodeLocation 的 code> 受到严格限制。不过,如果您直接将类文字传递给 Code ,它就可以工作:

import scala.mobile._

val c = new Code(classOf[scala.collection.mutable.StringBuilder])
c.apply[StringBuilder, String]("append")("Foo")
c.apply[String]("toString")()    // returns "Foo"
c.apply[Int]("length")()         // returns 3

看起来像是反射标准库中的另一个实现,稍微好一些。

I just checked the source code.

When Scala changed the name mangling of class files a few years ago and it seems people forgot to update these classes accordingly.

So my answer would be:

At least Location has no purpose, because it is not possible to get anything sensible out of it (except exceptions) and Code without Location is severely limited. It works though if you pass the class literal to Code directly:

import scala.mobile._

val c = new Code(classOf[scala.collection.mutable.StringBuilder])
c.apply[StringBuilder, String]("append")("Foo")
c.apply[String]("toString")()    // returns "Foo"
c.apply[Int]("length")()         // returns 3

Looks like yet-another implementation in the standard library of reflection-slightly-nicer.

梦在深巷 2024-11-09 22:33:48

Location 的描述很好地解释了它的含义:

Location提供了一个create方法来实例化对象
通过指定 jar/class 文件的 URL 地址从网络位置获取。

它可能被远程参与者使用。或许。

至于为什么它有这个误导性的名字?嗯,早在 2004 年,智能手机的普及率就很低,所以也许这种关联性并不那么强。

The description of Location pretty much explains what that is about:

The class Location provides a create method to instantiate objects
from a network location by specifying the URL address of the jar/class file.

It might be used by remote actors. Maybe.

As for why it has this misleading name? Well, back in 2004 smart phones had really low penetration, so maybe the association wasn't all that strong.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文