加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

有趣的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:“行为驱动设计框架”
> internal DSLs
> Squeryl:“Scala ORM和DSL用于与数据库通话,最小冗长和最大类型安全”

    def songCountByArtistId: Query[GroupWithMeasures[Long,Long]] =
      from(artists,songs)((a,s) =>
        where(a.id === s.artistId)
        groupBy(a.id)
        compute(count)
      )

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读