本文介绍了什么是 scala 的实验性虚拟模式匹配器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我看过很多少数 最近提到 Scala 的新虚拟化" 模式匹配器.我错过了解释它实际上是什么的备忘录......

I've seen quite a few mentions recently of the new "virtualized" pattern matcher for scala. I missed the memo explaining what it actually was...

推荐答案

虚拟化" 模式匹配器是对现有匹配器的重写.这样做的动机是为了支持多态嵌入式 DSL 的模式匹配虚拟化,与 2.10 无关.

The "virtualized" pattern matcher is a rewrite of the existing matcher. The motivation for doing this was to support virtualization of pattern matching for the polymorphic embedded DSLs, not relevant for 2.10.

正如 Iulian 在下面的评论中所说:它与 for-comprehensions 的编译方式非常相似:它们不是直接生成代码,而是被转换为 foreachmapfilter 等.然后模式匹配可以转换为一系列方法调用,DSL 可以覆盖这些方法调用.默认实现将尊重当前语义,挑战在于使其与当前语义一样高效.看来阿德里亚安已经非常接近这个目标了.虚拟化"实现更简单,并修复了当前实现中的几个错误.

As Iulian says in the comments below: It's very similar to how for-comprehensions are compiled: instead of directly generating code, they are translated to foreach, map, filter etc. Pattern matching could then be translated to a series of method calls, that DSLs could overwrite. The default implementation will respect the current semantics, and the challenge is to make it as efficient as the current one. It seems Adriaan is very close to this goal. The 'virtualized' implementation is simpler, and fixes several bugs in the current implementation.

多态嵌入式 DSL"是一种想法,即人们可能会在 Scala 中编写不应在 JVM 上运行的程序.也就是说,scalac 将产生一个描述程序正在做什么的输出.然后可以针对特定架构重新编译它.此类事情已在 ScalaDays 2011 上讨论过.

The "polymorphic embedded DSLs" are the idea that one might write programs in scala that are not supposed to be run on the JVM. That is, scalac will produce an output which describes what the program is doing. This may then be re-compiled against a specific architecture. Such things have been talked about at ScalaDays 2011.

这个重写最终会成为标准的scala模式匹配器.旧的模式匹配器(据我所知)无法维护.

This rewrite will eventually become the standard scala pattern matcher. The old pattern matcher was (as I understand it) unmaintainable.

这篇关于什么是 scala 的实验性虚拟模式匹配器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 10:24