This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-09-26
Channels
- # arachne (4)
- # beginners (70)
- # bigdata (1)
- # boot (373)
- # braid-chat (3)
- # cider (4)
- # cljs-dev (10)
- # cljsjs (6)
- # cljsrn (27)
- # clojars (11)
- # clojure (114)
- # clojure-austria (1)
- # clojure-czech (2)
- # clojure-dusseldorf (2)
- # clojure-greece (7)
- # clojure-italy (2)
- # clojure-nl (6)
- # clojure-russia (15)
- # clojure-serbia (11)
- # clojure-spec (92)
- # clojure-uk (5)
- # clojurescript (183)
- # component (9)
- # cursive (28)
- # datomic (36)
- # editors (4)
- # emacs (1)
- # garden (11)
- # hoplon (155)
- # lein-figwheel (7)
- # mount (47)
- # om (97)
- # onyx (25)
- # proton (3)
- # rdf (3)
- # re-frame (80)
- # reagent (9)
- # ring-swagger (9)
- # spacemacs (1)
- # untangled (145)
- # vim (2)
Is it possible to define a spec that depends on multiple keys within a map? e.g. ::date-1 must be greater that ::date-2
i'm getting "could not locate clojure/test/check/generators__init.class or clojure/test/check/generators.clj on class path"
@bcbradley that might be due to this: http://clojure.org/guides/spec#_project_setup
(defproject sand "0.0.1-SNAPSHOT" :description "FIXME: write description" :profiles {:dev {:dependencies [[org.clojure/test.check "0.9.0"]]}} :dependencies [[org.clojure/clojure "1.9.0-alpha12"]] :javac-options ["-target" "1.6" "-source" "1.6" "-Xlint:-options"] :aot [sand.core] :main sand.core)
If you are using Leiningen, you can try to put the dependency at the top level. So put it next to [org.clojure/clojure ...] in :dependencies
Yeah, just to check if that works. You might be using the test.check function in a way that does not fall under leiningen dev profile
(defproject sand "0.0.1-SNAPSHOT" :description "FIXME: write description" :dependencies [[org.clojure/clojure "1.9.0-alpha12"] [org.clojure/test.check "0.9.0"]] :javac-options ["-target" "1.6" "-source" "1.6" "-Xlint:-options"] :aot [sand.core] :main sand.core)
@bcbradley You’re AOT’ing that namespace so you’re forcing all those specs — including exercise-fn
— to run at compile time.
Ahead Of Time (compilation) — relating to the :aot
in your project.clj
Still, having the exercise-fn
call at the top-level of your code means it will be executed whenever that ns is run — put it inside -main
so it only runs when you run the -main
...
Same with generate
.
You’d normally put test code in a separate ns and have it run via one of the test runners.
In your project tree, you’ll see a test
folder next to src
.
Hmm, no, in your case you won’t — did you create that project manually?
(I’m not familiar with how NightCode creates projects… but normally lein new app myapp
will create a test
folder as well as a src
folder)
I’m surprised (and a bit disappointed) that NightCode doesn’t create a test
folder tree for all projects 😞
I think this is an issue with nightcode. A top level exercise-fn with :gen-class and aot would works
@thegeez Well, if test.check
is part of the regular :dependencies
yes, but you don’t want that code running at compile time or ns load time...
i don't wanna use emacs because its 2016, i don't like eclipse because its sluggish and smells of enterprise, i don't like intellij + cursive because i don't want to pay for it, I don't like netbeans because netbeans. Light table isn't working with clojure 1.9-alpha12
The majority of Clojure devs use a form of Emacs according to the annual "State of Clojure" surveys 🙂
jabbing aside, even after removing the AOT and pulling it into main i get some issues
@seancorfield yes that setup is not ideal, but more meant to isolate the problem
@bcbradley now you have the name my-index-of and a spec for my-index-of2
@bcbradley Your spec has my-index-of2
but the function … yeah, what @thegeez said 🙂
i know i'm probably being a pest, but can you explain the difference between clojure.spec and any normal library like clojure.set?
like for instance, i didn't know that i "shouldn't" invoke certain methods or macros at the top level
normally i wouldn't invoke anything at the top level in an application, but i figure heck
In general you don’t want any executable code at the top-level of your namespace.
What’s your language background, prior to Clojure? (so we’ll have a frame of reference for what you’re familiar with)
And regarding the difference between clojure.spec
and "normal" libraries, probably the big one is that there’s a bunch of "testing" stuff in clojure.spec
that belongs in test
code, where test.check
gets brought in via a :dev
profile (for REPL and running tests, as opposed to "production" line code). Does that help?
The specs themselves — and valid?
and conform
— are intended for production code, but the generative testing stuff (`generate`, exercise
, check
) is intended for either interactive use or for running as part of test code.
sorry i was away, my language background: C, C++, Java, Python, Javascript and then Clojure
i've got 8 years in C, 6 years in C++, 3 years in python, 2 years in javascript and 1 year in clojure
i'm in my senior year for software engineering and would like to get a job where the primary language is clojure, or at the very least some other functional oriented job with scala or erlang or whatever
i know how to use map, reduce, apply partial blah blah blah, i've been doing it for a while
'k so a Clojure namespace produces a class, and all the top-level forms become static initializers in that class… if you think of it in Java / C++ terms, those static initializers get run when a class is loaded, long before any class instance is created… so the same caveats apply.
so basically what you are saying is that if I have a bunch of top level forms that depend on some other class already being loaded, but it hasn't been loaded, i'll get a "class nil" error or some such
@bcbradley cursive is free for non-commercial use, fyi
Some of us really like yaks...
1.9.0-alpha13 is out https://groups.google.com/d/msg/clojure/QWPUWG9BwbE/9a7ymJb9AQAJ
which is mostly fixes and improvements to nilable, which is also probably a little faster