代码之家  ›  专栏  ›  技术社区  ›  Rob Lachlan

Clojure有语言规范吗?

  •  20
  • Rob Lachlan  · 技术社区  · 15 年前

    Clojure有语言规范吗?在ebnf中精确定义词汇语法和语法的东西还是类似的东西?

    我能找到的最接近的东西是 clojure website 但这并不能真正满足语言规范的要求(尽管它是一个非常好的资源)。如果没有规范,我们的BDFL有没有提到任何计划?

    4 回复  |  直到 7 年前
        3
  •  6
  •   Rayne    15 年前

        4
  •  0
  •   Thumbnail    7 年前

    user=> (defn)
    Syntax error macroexpanding clojure.core/defn at (REPL:1:1). 
    () - failed: Insufficient input at: [:fn-name] spec: :clojure.core.specs.alpha/defn-args 
    

    user=> (fn [3]) Syntax error macroexpanding clojure.core/fn at (REPL:1:1).
    (3) - failed: Extra input at: [:fn-tail :arity-1 :params] spec: :clojure.core.specs.alpha/param-list
    3 - failed: vector? at: [:fn-tail :arity-n :params] spec: :clojure.core.specs.alpha/param-list
    

    clojure.spec spec

    Clojure - clojure.spec: Rationale and Overview

    cat - a concatenation of predicates/patterns
    
    alt - a choice of one among a set of predicates/patterns
    
    * - zero or more occurrences of a predicate/pattern
    
    + - one or more
    
    ? - one or none
    
    & - takes a regex op and further constrains it with one or more predicates
    


    推荐文章