有趣的DSL,在Scala中实现?
发布时间:2020-12-16 09:22:21 所属栏目:安全 来源:网络整理
导读:我在Scala中看到了 BASIC和 Apache Camel DSLs,而且它们太棒了.这样的DSL的更多例子? 解决方法 你在MEAP(Early Access)书籍中有一个很好的来源 来自Debasish Ghosh的 DSL in action (博客:“Ruminations of a programmer) 像scalatest这样的测试框架是DSL
我在Scala中看到了
BASIC和
Apache Camel DSLs,而且它们太棒了.这样的DSL的更多例子?
解决方法
你在MEAP(Early Access)书籍中有一个很好的来源
来自Debasish Ghosh的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的框架: > specs:“行为驱动设计框架” def songCountByArtistId: Query[GroupWithMeasures[Long,Long]] = from(artists,songs)((a,s) => where(a.id === s.artistId) groupBy(a.id) compute(count) ) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |