我在斯卡拉见过BASIC和Apache Camel DSL,他们真是太棒了。还有更多这种DSL的例子吗?有趣的DSL,在斯卡拉实施?
15
A
回答
19
你必须在MEAP从Debasish戈什的良好来源(早期访问)一书
DSL in action(博客:“Ruminations of a programmer)
像scalatest测试框架是DSL的经典例子:
test("pop is invoked on an empty stack") {
val emptyStack = new Stack[String]
evaluating { emptyStack.pop() } should produce [NoSuchElementException]
emptyStack should be ('empty)
}
还有很多其他基于DSL的框架:
def songCountByArtistId: Query[GroupWithMeasures[Long,Long]] = from(artists, songs)((a,s) => where(a.id === s.artistId) groupBy(a.id) compute(count) )
6
lift-json提供了一个DSL来生成JSON。例如,下面的DSL:
("person" ->
("name" -> "Joe") ~
("age" -> 35) ~
("spouse" ->
("person" ->
("name" -> "Marilyn") ~
("age" -> 33)
)
)
)
创建以下JSON:
{
"person": {
"name": "Joe",
"age": 35,
"spouse": {
"person": {
"name": "Marilyn",
"age": 33
}
}
}
}
1
两个很好的例子是解析器组合和演员内置的DSL。有一个叫做DBC的SQL包装器(尚未准备就绪),在这里你可以看到它是怎样的:http://scala.sygneca.com/libs/dbc
0
ScalaQL论文(PDF)描述了一个有趣的DSL语言集成数据库查询的实现。
1
XML in Scala是另一个例子。
2
ScalaModules是一款适用于OSGi的DSL。
另一种可用于Apache Camel的企业集成平台。
Scala-Query和Squeryl还提供用于查询数据库的DSL等等。
ScalaTest也是一个很好的例子。
0
相关问题
- 1. DSL斯卡拉
- 2. DSL类似的语法在斯卡拉
- 3. 创建使用幻影斯卡拉DSL
- 4. 斯卡拉SQL DSL(内部/外部)
- 5. 斯卡拉DSL仅适用于括号
- 6. 在播放斯卡拉网络插座的oauth2实施
- 7. 斯卡拉DSL没有额外的语法
- 8. 有趣的地图和flatMap观察 - 未来,斯卡拉
- 9. 斯卡拉消息总线实施的演员?
- 10. 斯卡拉在斯卡拉类
- 11. 在斯卡拉
- 12. 在斯卡拉
- 13. 在斯卡拉
- 14. 在斯卡拉
- 15. 在斯卡拉
- 16. 在斯卡拉
- 17. 在斯卡拉
- 18. 在斯卡拉
- 19. 在斯卡拉
- 20. 在斯卡拉
- 21. 在斯卡拉
- 22. 在斯卡拉
- 23. 在斯卡拉
- 24. 在斯卡拉
- 25. 在斯卡拉
- 26. 在斯卡拉
- 27. 在斯卡拉
- 28. 在斯卡拉
- 29. 在斯卡拉
- 30. 在斯卡拉
真的很好的书。还包括其他语言,以便您可以比较DSL在不同语言中的感受。 – 2010-08-11 19:31:25
优秀的书。 Ghosh先生特别好地介绍了Scala(这是我阅读的部分)。另外,您可能想要阅读Spiewak先生关于Parser Combinators(对外部Scala DSLs至关重要)的教育,写作良好的文章 - www.codecommit.com/blog/scala/the-magic-behind-parser-combinators – 2014-01-14 18:47:18