This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-09-09
Channels
- # admin-announcements (23)
- # beginners (7)
- # boot (6)
- # clara (1)
- # cljs-dev (2)
- # clojure (89)
- # clojure-argentina (1)
- # clojure-australia (5)
- # clojure-brasil (4)
- # clojure-denmark (2)
- # clojure-france (1)
- # clojure-italy (1)
- # clojure-japan (9)
- # clojure-nl (13)
- # clojure-russia (1)
- # clojurescript (248)
- # clojurex (3)
- # clojutre (3)
- # core-async (2)
- # datomic (6)
- # devcards (19)
- # devops (1)
- # events (1)
- # funcool (9)
- # hoplon (74)
- # ldnclj (53)
- # melbourne (3)
- # off-topic (25)
- # onyx (36)
- # reagent (8)
Is it the case generally that one has to mangle hyphens in import statements to underscores
@tel: I believe that’s correct. import clauses are for java interop, so you play by java rules.
Yeah I was less than pleased when I saw that. Makes some amount of sense (they get compiled to classes I believe), but still a little onerous for users.
just, a pretty sharp edge forcing one to come to terms with Clojure being a little less of a language and a little more of syntax sugar for Java 😕
->RecordName
is the positional constructor, there's also a map-based constructor you get for free map->MyRecord
that takes... drum roll, a map
you'll only need the class for interop where java has to call in to you. if it's just protocol extension, no need for class
(ns whatever-source
(:require [the-other-ns :as foo]))
then later...
(extend-protocol MyProtocol
foo/MyRecordOverThere ....)
@ghadi: So you’re saying the following should work?
In tester/core.clj
:
(ns tester.core)
(defrecord MyRecord [])
In tester/other_ns.clj
:
(ns tester.other-ns
(:require [tester.core :as c]))
(defprotocol MyProto
(-my-fn [this]))
(extend-protocol MyProto
c/MyRecord
(-my-fn [this]
"HAHA"))
For the record, that doesn’t work for me. My understanding was that you had to have something like:
(ns tester.other-ns
(:require [tester.core :as c])
(:import [tester.core MyRecord]))
“Doesn’t work” meaning I get the following:
CompilerException java.lang.RuntimeException: No such var: c/MyRecord, compiling:(/path/to/tester/other_ns.clj:7:1)
I've written a blog post about this -> http://matthewboston.com/blog/clojure-protocol-namespaces/
and now @ghadi has got me wondering...
I wish Clojure was providing a private def- the same way it provides defn- (I know it’s easy to define, I just wish it was part of Clojure).
I wish there was a way to specify implicit namespace(s), this way I could “extend” core with my helper library and it would feel like using core
@darwin: Vinyasa inject could do that: https://github.com/zcaudate/vinyasa and another option is to use Potemkin import-vars to build one "sweet" ns with all the helpers so instead of e.g. five util namespaces you only need to require one
@juhoteperi: thanks
@jellea: About geom, is there any helper function to get the range and pos? They are kind of weird to get right myself
It certainly works awesome for in-team communication, not sure how it works out on this scale since I'm here only for a few days, but some seem to prefer gitter.
Some things are better than IRC. Automatic history even when offline is one thing I certainly appreciate
@emil0r @jaen The community has logs set up to get past the 10k message limit, although yeah I would love to be able to not have to resort to such things. Unfortunately slack are not very receptive to having an option for F/OSS communities within their pricing structure. To “level up” at our current capacity it would cost me in excess of $60,000-$130,000 (depending on the plan) per year, money I don’t have 😕
I have been thinking about, and trailing other solutions, that will give us more functionality, without taking away the experience. However there is no concrete answer yet.
I'm looking to generate some random data for an API proof of concept, sort of like test check generators.. I found http://clojure.github.io/data.generators/index.html but it wonder if there is something better or easier ?
I'm frustrated with clojure.test. I have a bunch of tests that all follow the same structure, and I'm forced to use a monolithic macro to get meaningful line numbers. What's the easiest thing out there that will let me hook into reporting, and still give like junit xml output with clojure-maven-plugin? When I'm considering writing a dsl to test my dsl, something feels off .
as I process items I'm looking for ones that are a list
and if so I break the list into 2 pieces, the base data and some parameters, and then I'm putting those parameters into a map indexed by the position of the item in the new coll being produced.
then I need some way to get this map out of this stateful transducer so I simply pass it to the reducing function during the finalizing step
here is the code:
(defn split-module-params-xf
"Returns a stateful transducer that accumulates a map of module parameters,
where the key is the index position of the module in the resulting word."
[]
(fn [rf]
(let [data (volatile! {})
index (volatile! 0)]
(fn
([] (rf))
([result] (rf result [@data]))
([result input]
(let [v (vec (for [[n, module] (map-indexed vector input)]
(if (list? module)
(let [[module param] module]
(vswap! data assoc (+ @index n) param)
module)
module)))]
(vswap! index + (count v))
(rf result v)))))))
this is part of my L-system (parallel rewriting system) so the code reflects the names from that domain
a word
is just any coll
and a module
is any item in that coll
and using a list
to signify optional parametric data is just a convention I settled upon.
since previous steps in the transducing process can return more items I need to track the index position that it will be in the new word
@nullptr: thanks generate from schema is perfect