This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # bangalore-clj (3)
- # beginners (23)
- # boot (89)
- # cider (11)
- # cljs-dev (22)
- # cljsjs (5)
- # cljsrn (21)
- # clojure (141)
- # clojure-android (1)
- # clojure-berlin (1)
- # clojure-greece (1)
- # clojure-italy (13)
- # clojure-mke (2)
- # clojure-nl (8)
- # clojure-norway (5)
- # clojure-russia (22)
- # clojure-sg (4)
- # clojure-spec (38)
- # clojure-uk (109)
- # clojurescript (150)
- # consulting (4)
- # core-async (7)
- # cursive (13)
- # datascript (8)
- # datomic (72)
- # dirac (185)
- # emacs (5)
- # figwheel (2)
- # flambo (1)
- # hoplon (13)
- # immutant (6)
- # lambdaisland (7)
- # lumo (46)
- # off-topic (13)
- # om (4)
- # onyx (1)
- # pedestal (1)
- # re-frame (68)
- # reagent (15)
- # rum (16)
- # slack-help (4)
- # spacemacs (22)
- # specter (3)
- # vim (10)
- # yada (28)
what I’d like to be able to state is “I only care about the first argument and it should be a grid ”
@slipset That's what you're stating with that spec, though, isn't it? 😄 If you feel it's too noisy and/or you're going to use it in many places, you could define a macro that hides that noise.
apart from that, it seems like spec is giving me exactly what I want: the possibility to sprinkle “types” over my program when it’s “done”.
myproj/myns.clj contains a function, which requires specs defined in
myproj/specs.clj. I have the function
fdef'd and it currently sits next to the function itself in
myns. However, I'd like to move the function spec away from the function itself. So
myns depends on
specs, but the fdef'd function depends on knowing about the function itself in
myns, so I can't move it to
specs. Circular dependency. Where are you putting your spec'd functions (or in general, any of your specs) in your project?
misha: so you have to require that ns in your spec file? or otherwise define it there? that seems odd, but i'm a relative noob at spec.
requireing needed. afair, spec just uses fn symbol to register spec, and does not call actual fn, so the actual require'ing is not needed
many thanks to you both -- @ghadi , by "the specced namespace" you mean
specs in my example above?
yourproj.specs should depend on yourproj.myns, not the other way around, like @misha 's example
myns might not need specs imported unless it uses one for explicit validation as a workflow step
then either keep fdef's closer to functions, or use fully qualified fn names in fdefs w/o explicit imports
mobileink: I'd say: only if you need to call something from that ns, or import for side effects.
alias works w/o explicit import (at least it worked for me just now)
hmm, need to experiment more. i could swear i've used :foo.bar/baz without require or import, but theres a goid chance i misunderstood what i was doing. ;)
i didn't think you could alias an ns without "making" it whether by require or sth else. i.e. just a symbol won't work. but i'm away from my machine, will try later.
I am trying now, and I see no spec ns import required either: I can define specs for functions in
foo.specs w/o importing
foo.fns, and can use specs for assertions in
foo.fns w/o importing
time for me to take another sip from the firehose. not so easy when your lips have already been ripped off!
two namespaces, neither imports the other. instrumentation and validation work, because specs get registered in global registry
I have spec guide open at all times while doing spec development, for quick reference https://clojure.org/guides/spec
me too - just haven't needed to deal with fns yet. it's hard enough to figure out how to do what i need with maps!
require use case I can think of now – is google closure compiler advanced optimization, where specs might get dead-code-eliminated. Haven't tried that yet though
fwiw i just got my clj map specs working in cljs, using cljc code. works like a charm - but haven't done advanced opt yet. shivers