我在斯卡拉見過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. 實施,在斯卡拉
- 2. DSL斯卡拉
- 3. 斯卡拉DSL -
- 4. 實施ExpandoObject斯卡拉
- 5. DSL類似的語法在斯卡拉
- 6. 斯卡拉DSL僅適用於括號
- 7. 創建使用幻影斯卡拉DSL
- 8. 斯卡拉SQL DSL(內部/外部)
- 9. 斯卡拉幻象DSL主機
- 10. 克魯斯卡實施
- 11. 在斯卡拉強制實施工廠的簡明方法
- 12. 在播放斯卡拉網絡插座的oauth2實施
- 13. 卡桑德拉CQL實施
- 14. 有斯卡拉
- 15. 斯卡拉DSL沒有額外的語法
- 16. 有趣的地圖和flatMap觀察 - 未來,斯卡拉
- 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