clojure.spec - David Nolen

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 ต.ค. 2024

ความคิดเห็น • 12

  • @kap4020
    @kap4020 7 ปีที่แล้ว +15

    love watching David Nolan's presentations

  • @nathansire6951
    @nathansire6951 5 ปีที่แล้ว +4

    Clojure community just keeps pulling me back in everytime I see such great innovations. I envy this unit test generation tool. I want it in Ruby.

  • @gary000
    @gary000 7 ปีที่แล้ว +11

    also when " (s/conform ::person {::first-name "David" ::last-name "Nolen" :age 37})" failed you should have immediately done "(s/explain ::person {::first-name "David" ::last-name "Nolen" :age 37})" to show the power of spec. Because if that had been a deeply nested structure that you couldn't just eye-ball and say "oh yea I forgot to use the namespace qualified version of the age keyword," explain would have shown you exactly where the issue was. When I reran that example at the repl it said "fails spec: vienna-js.core/person predicate: (contains? % :vienna-js.core/age)"

  • @brianbeckman4982
    @brianbeckman4982 7 ปีที่แล้ว +4

    I'd be grateful for a bit of detail on ":tree" versus "::tree" in the recursive spec. It wasn't immediately clear to me why you have two different keywords, whether you must have two different keywords (to stop the recursion?), and how :tree is related to ::tree (one of the two is implicitly name-spaced iirc).

    • @TomaszMachalski
      @TomaszMachalski 7 ปีที่แล้ว +1

      Brian Beckman :tree is a key in the map which represents tree structure, while ::tree is the name of the spec itself.

    • @primitiveinds
      @primitiveinds 7 ปีที่แล้ว

      I think the first keyword has to do with the representation of the spec (e.g. when you call s/conform and get a map as a result), and the 2-colon keyword (namespaced) is the actual spec. So, instead of :tree you can write :foo and the spec still works, but there is a difference in the map output. (not completely sure, of course)

    • @FergalByrne
      @FergalByrne 3 ปีที่แล้ว

      Both replies correct. :tree is the spec’s name for that part of the data, and it has to be a ::tree

  • @gary000
    @gary000 7 ปีที่แล้ว +1

    not sure how I feel about versioning a spec. if you have a spec that is called ::firstname that is a string and you want it to change it to instead be the hex value of the first name, would you make ::firstname-v2 or just call it ::hexed-firstname ? in both cases you're giving it a new name because spec doesn't allow versioning in the sense that you have the same name and then your build tool gives you the right version of the thing at compile time, but still, when David said "versioned specs" I shivered a little bit

  • @bichitomax
    @bichitomax 7 ปีที่แล้ว +1

    Novel? Is a complete ripoff from Racket (or any languages) contracts system, nothing new here.

    • @michaelnardell991
      @michaelnardell991 7 ปีที่แล้ว +6

      In fairness, I believe the clojure.spec documentation is quite clear on this: "Almost nothing about spec is novel. " (clojure.org/about/spec)

    • @nathansire6951
      @nathansire6951 5 ปีที่แล้ว

      Isn't racket a static typed clojure? And clojure spec is more of a unit/data permutation testing solution?

    • @peterkerj7357
      @peterkerj7357 5 ปีที่แล้ว

      @@nathansire6951
      >Isn't racket a static typed clojure?
      no lol