Fork me on GitHub
#clojure
<
2017-05-19
>
misha00:05:00

sequentiality is not a hard requirement, it just needs to advance in the same direction (decrease in this case)

bcbradley00:05:23

i know someone who had a similar problem in c++ (unique ids) and they just decided to use the current time multiplied by the hardware thread index as the unique id

noisesmith00:05:49

we do have uuids if we need to go that far

bcbradley00:05:52

leave it to c++ programmers to make something so ugly xd

misha00:05:33

for a moment I considered to use (clojure.lang.RT/nextID), but then again, I need to find cljs alternative too (also make it negative), and the same argument applies: too much obscure code for a negative int

bcbradley00:05:25

what are you working on btw, if you don't mind indulging my curiosity

misha00:05:40

I'd use datascript's fn, but I try to keep dependencies at zero. which brings me to next question: how do you depend on a few library's functions, w/o depending on the library in project.clj? I went with config hash-map, which gets passed all over the place under the hood. Are there other alternatives?

bcbradley00:05:26

(:require [lib :refer [foo bar]]) i think

bcbradley00:05:55

oh wait i misunderstood you

john00:05:12

Are you checking for the availability of the lib?

misha00:05:28

I want to package code as a lib foo, which uses fns from lib bar, but do not include it as a dependency, rather ask to supply particular functions at client setup time

noisesmith00:05:09

@misha make a function that takes the implementation as an arg, and supply a simple reasonable default

john00:05:47

I've stored the config in an atom. Rather than passing it around

misha00:05:15

I tried datascript with react native, and it is very slow on iphone 5. I moved it to a separate thread, but RN adds like 50ms to a messages between threads, + datascript is not instantaneous itself, so I decided to build a cache layer to be used in a main thread, for fast reads and optimistic updates, which will talk to a db-thread

misha00:05:04

@noisesmith there are no alternative implementations: I need 4 particular datascript functions, but want to avoid bumping up dependencies.

noisesmith00:05:14

normal clojure dependency resolution makes it simple for the end user to select their version

misha00:05:20

db-thread then will have all the time in the world to: sync with datomic, transact stuff, etc.

noisesmith00:05:21

this isn’t something you need to solve

misha00:05:37

like

:dependencies
 [["foo-1" :exclude ["bar-2"]]
  ["bar-3"]]
?

noisesmith00:05:29

or just :dependencies [[bar “3”] [foo “1"]]

noisesmith00:05:39

the default rule is to use the first provided, and closest to the top level

misha00:05:40

imperative!

misha00:05:24

All that Rich'es talk was for nothing then opieop

noisesmith00:05:29

that’s why you don’t get somebody else’s version of clojure.core - because everyone puts clojure as their first dep as lein puts it there

noisesmith00:05:49

so it overrides the various clojure.core versions referenced by libraries

misha00:05:26

this is not critical, I know, it's just what I took stab on to keep things interesting

noisesmith00:05:01

it’s also possible to use a :provided scope for a dependency, which declares that you never ship that lib and the user will always provide it

noisesmith00:05:31

but really just letting people override versions in the normal way suffices for this

misha00:05:42

I did not find a good/any description of :provided when I was looking some time ago, and that sounds like the best option so far (as long as I will put it in a readme, hehe)

noisesmith00:05:06

that would just be annoying - people would ask why they have to add a dep by hand for something you use

noisesmith00:05:27

or no? would people always be using the lib already if they use yours?

misha00:05:10

yes, they would, since it is a caching layer specifically for datascript. zero value w/o one. on the other hand, I am always annoyed when I need to go and bump version all over the util-libs I have, instead of just do it in a client application

sailxjx06:05:07

Hello everyone, I’m new to clojure, could anyone tell me how to avoid use exceptions in clojure? For example, I have an function to check user input params and block the coming steps when the param is invalid, how to refactor the following code?

(defn check-params
  "Check my params"
  [params]
  (if (:required-key params)
    params
    (throw (Exception. "Missing required keys"))))

carocad07:05:53

@sailxjx I prefer returning an ex-info instance. That way you can have a function that check if the returned value was an error and fetch extra information is necessary (logging) for example.

sailxjx07:05:39

@carocad return an ex-info or throw an ex-info?

carocad08:05:33

Return it. Check out the instaparse project. They use that approach as well. You can the check the type of the returned value as see if it is an exception. If so then you know the processing failed

leonoel08:05:36

@carocad what is the benefit compared to a try/catch ?

leonoel08:05:17

carocad: monad is not a prerequisite for an idea to be good

leonoel08:05:56

I still don't get the point of reinventing exception mechanism

leonoel08:05:38

especially if you're just interested in the "stop computation on error" feature, as is precisely the default behavior of exceptions

carocad08:05:34

@leonoel monads? sorry I had to delete that message because it was the wrong blog post 😅, please see the editted link

carocad08:05:25

nevertheless, I never said that any other idea was bad, nor that my idea was the right one. I simply said: "I prefer to return an ex-info", which is just a personal opinion

carocad08:05:20

I get your point about the exception mechanism and I agree that there is no point in reinventing it if that would be the case. Nevertheless in some cases, you are dont want an exception to be thrown, because an error can be an expected behavior. Just like the name says, an exception is an exception to the normal flow of a program. But if the program expect the computation to fail should you still throw?

attentive08:05:56

There are some pretty sound reasons not to use exceptions for flow control—one of which is that error data isn't explicitly surfaced in your enclosing APIs which means client code tends not to bother handling errors. The Either monad (and variants) is a pretty good way to fail out of a set of nested might-fail functions in the presence of a known error condition without adding too much cruft to your code, or using the nuclear option of unwinding the stack with an exception.

leonoel09:05:57

@carocad this post is more pragmatic but not really advocating returning ex-info instead of throwing it, right ?

carocad09:05:41

right. The only advice there is not to return nil as error since the user of the functions would not know why did something fail. Throwing and returning ex-info are more of an opinion. I prefer returning them but ymmv 😉

leonoel09:05:41

I'm just trying to understand why one programming style is preferred to the other

leonoel09:05:02

returning a special value in case of error forces the caller to add a check

leonoel09:05:46

wrapping the value in an either monad is basically the same strategy : you force the caller to care

carocad09:05:32

yes but if you throw an error then it will throw you away the flow of the program even if you expected an error to happen. For example: (sequence (comp (map f1) (filter f2) (map f3)) a-sequence-that-might-fail If either f1, f2 or f3 fail for a single element then your complete computation is thrown away because you will go to the catch statement.

carocad09:05:03

nevertheless if you know that one of those operations might fail the you can simply do: (sequence (comp (map f1) (remove failure?) (filter f2) (map f3)) a-sequence-that-might-fail

leonoel09:05:23

all computation can fail, the important question is, should the error be recovered ?

carocad09:05:25

The second options lets you decide how to handle the error. You might ignore it or you might throw it. Again, it depends on the flow that you want to encourage of your api

leonoel09:05:23

yes, it's all a matter of api design choices

leonoel09:05:26

who is in charge of deciding if errors of a given type have to be recovered ?

leonoel09:05:36

the api designer or the api consumer ?

carocad09:05:58

jeje now we are getting too philosophical 😄

leonoel09:05:14

error handling is a big topic for sure 🙂

carocad09:05:09

yeah, every programing language struggles with that question. Precisely because it get very subjective about who should decide what and how 😄

cmal08:05:15

Hi, how can ring get the form data from a request, I currently can get query-params , multipart, keyword-params, but I don't know how to get the js formdata.

(def svc-app
  (wrap-routes main-routes
               #(-> %
                    wrap-reload
                    keyword-params/wrap-keyword-params
                    cookies/wrap-cookies
                    params/wrap-params
                    mp/wrap-multipart-params)))

quan08:05:59

cmal: :form-params or :params for all params

cmal08:05:09

I found if I send the POST request using x-www-form-urlencoded, I will get the form-params, but if I send the POST request using js/formData the form-params will like this:

:form-params {"------WebKitFormBoundaryu7BKnalMAs1Vg5qP\r\nContent-Disposition: form-data; name" "\"token\"\r\n\r\n91827fc3227c5ba631ba53435327374273c45fa0\r\n------WebKitFormBoundaryu7BKnalMAs1Vg5qP\r\nContent-Disposition: form-data; name=\"statement\"\r\n\r\n1212\r\n------WebKitFormBoundaryu7BKnalMAs1Vg5qP--\r\n"}

cmal08:05:41

This is the result when using x-www-form-urlencoded:

:form-params {"token" "91827fc3227c5ba631ba53435327374273c45fa0", "statement" "(financial/query-latestinfo \"300182\")"}

cmal08:05:10

Ahh, I see, I was wrong with the content-type header.

cmal08:05:35

I found if I send the POST request using x-www-form-urlencoded, I will get the form-params, but if I send the POST request using js/formData the form-params will like this:

cmal08:05:48

:form-params {"------WebKitFormBoundaryu7BKnalMAs1Vg5qP\r\nContent-Disposition: form-data; name" "\"token\"\r\n\r\n91827fc3227c5ba631ba53435327374273c45fa0\r\n------WebKitFormBoundaryu7BKnalMAs1Vg5qP\r\nContent-Disposition: form-data; name=\"statement\"\r\n\r\n1212\r\n------WebKitFormBoundaryu7BKnalMAs1Vg5qP--\r\n"}

qqq09:05:31

at a clojure repl, is there . away to type in the name of a java class and get the documnetatio nf said class ?

qqq09:05:38

(I'm thinking via reflection or something)

jumar09:05:21

@qqq I don't think it's possible via reflection. Some environments support javadoc documentation for given symbol (e.g. cider-doc) - for standard java classes you can still use javadoc function (which will only open online documentation)

qqq09:05:46

jumar: I see, so basically all tools call javadoc

jumar09:05:28

I wouldn't say that - Cursive certainly has internal mechanism how to show javadoc for given class. not sure about cider, but in cider it also works for non-JDK classes for which you add sources to the classpath

qqq09:05:30

right, but Cursive is also using javadoc to get the actual docs right?

qqq09:05:53

what I meant to say: "the standard way 5toget docs for a class is via javadoc; and you can figure out how to display it later"

qqq09:05:27

alright, I've had enough of clojure.java.jdbc I want something higher level

qqq09:05:37

what higher level lib should I look into?

qqq10:05:16

(j/with-db-connection [conn db-spec] (j/execute! conn (j/drop-table-ddl :letters))) gets me d.font=> PSQLException ERROR: statement cannot follow a schema change in a transaction org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse (QueryExecutorImpl.java:2455) how do I drop a table in jdbc ?

lincpa10:05:49

try set transaction is false in execute!

lincpa10:05:32

(execute! db sql-params) (execute! db sql-params opts) The :transaction? option specifies whether to run the operation in a transaction or not (default true).

qqq10:05:18

@lincpa: that fixed it; thanks!

lxsameer12:05:13

hey guys, what tool do you use for database migration ?

donaldball12:05:39

lxsameer: migratus these days

lxsameer12:05:13

does it supoprt cassandra ?

donaldball12:05:40

Oh, I doubt it. IIRC it’s tooling is built around a fairly simply protocol, but cassandra may have unique requirements

mpenet13:05:59

there was ragtime-alia, never used it tho

mpenet13:05:07

joplin also supports cassandra (via alia too)

mpenet13:05:21

the latter is probably more up to date

lxsameer13:05:40

i tried that before, Joplin is so buggy

mpenet13:05:10

never used it either, maybe you might want to ping #juxt people (I am just aware of it because of alia really)

lxsameer13:05:34

what's juxt ?

mpenet13:05:25

(authors of joplin)

nha13:05:26

I use joplin, if you plan to use it be sure to have a look at https://github.com/juxt/joplin/issues/8#issuecomment-152650634 . Apart from that it is alright

lxsameer14:05:56

@U0ALP2929 i don't want to use it any more but I'm going to check the out for sure, thanks

nha14:05:01

We talked about the bad points of joplin but what I like about joplin is that I can use it from my code, as a library. It means it is very easy to add things like logging etc. with your migrations, which can be useful for debugging/monitoring etc. But I nearly dropped it several times, due to the issue above. (note, I use it on a personal project, not at work)

cmal14:05:59

Hi, how can I get all routes under some /path in compojure? for example, I want to match all /path, /path/a, /path/a/b/c, /path/v/e/r/y/long and so on to run in one handler? Or, maybe a wildcard matches such as /path/*?

michaellindon14:05:46

i never seem to have a need for macros, am i doing clojure wrong

cmal14:05:50

@michaellindon The author of book Clojure Programming says: You can go a long way before you start to use macros in clojure.

michaellindon14:05:27

@cmal one of the main selling points of Clojure is the ease with which one can create macros... seems like I'm missing out on one of the main advantages of the language. Either my applications rarely need them or my brain is not wired to think in macros

tatut14:05:12

First rule of macro club: don’t use macros.

tatut14:05:25

Second rule (for experts only): unless you really need to

zylox14:05:48

macros tend to be a modification of a reasoning model (in my experience). So it would just mean your reasoning model is in line with the base patterns of the language.

zylox14:05:16

plus things get hairy quick with macros, so you want to tread carefully anyway.

michaellindon14:05:34

thats good to know. It felt like I was missing out on some superpowers by not using macros

tatut14:05:43

In some way you are, but normal code doesn’t need superpowers

chrisn14:05:23

Do protocols have an argument count limit?

chrisn14:05:20

CompilerException java.lang.RuntimeException: Unable to resolve symbol: ct->tensor in this context, compiling:(/home/chrisn/dev/cortex/src/cortex/verify/tensor.clj:138:17) 
user> (defprotocol test-proto
        (test-fn [arg0 arg1 arg2 arg3
                  arg4 arg5 arg6 arg7
                  arg8 arg9 arg10 arg11
                  arg12 arg13 arg14 arg15
                  arg16 arg17]))
test-proto
user> (test-fn 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17)
CompilerException java.lang.IllegalArgumentException: No single method: test_fn of interface: user.test_proto found for function: test-fn of protocol: test-proto, compiling:(*cider-repl cortex*:51:7) 
user> (defprotocol test-proto
        (test-fn [arg0 arg1 arg2 arg3]))
test-proto
user> (test-fn 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17)
CompilerException java.lang.IllegalArgumentException: No single method: test_fn of interface: user.test_proto found for function: test-fn of protocol: test-proto, compiling:(*cider-repl cortex*:56:7) 
user> (test-fn 1 2 3 4)
IllegalArgumentException No implementation of method: :test-fn of protocol: #'user/test-proto found for class: java.lang.Long  clojure.core/-cache-protocol-fn (core_deftype.clj:568)
user> 

chrisn14:05:48

I would expect the last error every time (no implementation).

chrisn14:05:25

No, my error.

chrisn14:05:30

0 based indexing...

tmcw17:05:17

I have a somewhat noob'ish question if anyone feels like entertaining it! I'm working on a transpiler-of-sorts, and it uses clojure.walk/postwalk to assign types to expressions, starting at the leaves of the tree (that comes from edn) and going up. as far as I can see... when I modify leaf nodes and then try to 'access' those leaf nodes from their parent in the tree, they aren't modified

tmcw17:05:44

so... is postwalk sort of creating an immutable copy and the tree you're accessing doesn't change as you traverse it?

tatut17:05:25

what do you mean by “modify leaf”?

tmcw17:05:42

by modify leaf, i mean... when it's at the bottom of the tree, it uses with-meta to add metadata, and then i'm trying to basically progressively move that metadata up the tree

tatut17:05:54

(clojure.walk/postwalk #(if (number? %) (inc %) %) {:foo 1 :bar {:nested 41}})
=> {:foo 2, :bar {:nested 42}}

tmcw17:05:14

i've been confused because when i get to the bit where it looks for child nodes to have metadata ([here](https://gist.github.com/anonymous/a7c1e7f4f9a7cf3bce3209c8a40fac09#L134)) it isn't finding that metadata set

tmcw17:05:33

but if i log the places that postwalk traverses, i know that the metadata has been set... somewhere

tmcw17:05:53

let me see if i can make a distilled example..

tmcw18:05:59

whoah. okay, was in a totally different bug land than i expected 🙂 til that list? is not a very robust way to check for general listiness, seq? covers all the bases in this case

john18:05:44

@ba lol sorry 🙂

ba18:05:39

haha no worries, I'm in a lot of slack communities so its good to occaisionally get reminded that one exists 😄

john19:05:41

I meant "bad ass" 🙂

noisesmith18:05:17

@tmcw postwalk creates a new collection, the new collection it created has your new metadata

noisesmith18:05:05

we don’t really update things in place, other than vars, atoms, refs, agents

noisesmith18:05:10

and a hash map is none of those

noisesmith18:05:44

with-meta returns the hash-map but with different metadata, not changing the metadata on the item you were looking at

tmcw18:05:19

gotcha, i'm more wondering... the function that's called for each node by postwalk - is it called on the new tree (and thus has the modifications of previous traversal steps) or are the methods always called on the old, original tree

noisesmith18:05:27

it should be on the new one, but I wouldn’t be surprised if there was a subtle metadata bug - those happen a lot

tmcw18:05:45

👍 that's what the current operation of the code suggests, which is great

tmcw18:05:00

(not the thing about metadata bugs, i hope i don't run into one of those :)

noisesmith18:05:33

it might save some trouble to define a two-way transformation into a node structure that explicitly shows that data (at the cost of hiding the “real value” under a sub key of course)

noisesmith18:05:10

similar to how clojure.tools.analyzer.jvm represents the AST https://github.com/clojure/tools.analyzer

tmcw18:05:46

huh... why wouldn't analyzer use the metadata system?

noisesmith18:05:53

because they found it more reliable to describe everything about an ast as data - in terms of printing, less gotchas where you unexpectedly lose metadata, etc.

noisesmith18:05:15

but someone who works on that project might have a better answer than I

tmcw18:05:24

got it, cool! i'll consider that if i end up needing to store / debug information more in this tree ast

bronsa18:05:23

metadata isn't very robust and not all expressions can accept metadata

bronsa18:05:52

also the AST that tools.analyzer produces is not always 1:1 with the underlying code

tmcw18:05:18

that's a bummer about not being able to trust metadata, was pretty hopeful about that part of the language

mobileink19:05:48

@bronsa what do you mean by "not very robust"?

john19:05:28

I think the intended use case was suppose to be "about" data, and never to be used in a way that affects the identity/equality of the value. Not sure if that pertains to this use case or not.

noisesmith19:05:27

it’s not robust in that many people use functions that don’t preserve metadata - clojure.core probably fixed this in most cases by now, but random other libs likely haven’t

noisesmith19:05:50

this means to use metadata reliably you need to agressively re-apply metadata after using the data

mobileink19:05:12

ok. i'd call that a matter of transparency rather than robustness, fwiw. metadata behaves the way it's designed to behave, i hope, since i'm using it a lot.

bronsa19:05:45

@mobileink yeah, I meant that as "using metadata to represent ASTs isn't a very robust approach"

mobileink19:05:04

maybe i'll need to rewrite my libs for v. 2. 😢

bronsa19:05:20

metadata is fine per se

fabrao19:05:18

Hello all, how to write new String[]{"id","text"} from Java in clojure?

noisesmith19:05:39

(into-array String [“id” “text”])

fabrao19:05:45

hummmm, thanks

tmcw19:05:21

are there any tricks for debugging test assertions that print exactly the same?

noisesmith19:05:59

there’s extra parens in the fail case

noisesmith19:05:13

lein difftest makes such things more obvious in my experience

tmcw19:05:54

i'm not sure the parens are... real? like if I add (first, then the 'actual' result becomes 'module', same as the expected

noisesmith19:05:21

clojure.test does not insert fake parens

tmcw19:05:13

here's what that looks like in ultra:

tmcw19:05:38

no extra parens there, but a puzzling comparison of nils

noisesmith19:05:52

nil means “no difference”

noisesmith19:05:56

the difference is the two 0

noisesmith19:05:14

maybe someone did (symbol “0”) which is not equal to 0 but prints the same (and is an abomination btw)

tmcw19:05:07

oh... :thinking_face:

noisesmith19:05:38

but the symbol function totally lets you do that

peregrine.circle=> (symbol "0")
0
peregrine.circle=> (= 0 *1)
false

tmcw19:05:32

👍 back on the hunt, thanks

noisesmith19:05:22

you could add a test that the 0 there is not a symbol - narrow down to the failure

markbastian19:05:06

Hey folks, I was wondering if I could get some tips on pre/post conditions. When looking at http://blog.fogus.me/2009/12/21/clojures-pre-and-post/ and in practice, when the precondition fails all you get is an AssertionError. Any way to get a better report of the error, especially the location where it happened?

markbastian19:05:46

It'd be nice if it told you the function or ns where it occurred.

noisesmith19:05:06

stack traces will tell you both the function and ns

noisesmith19:05:16

and when assertion errors are thrown you should get stack traces

markbastian19:05:24

well, I thought so, but maybe I am doing something wrong. Here's an example:

markbastian19:05:24

(defn constrained-fn [f x] {:pre [(pos? x)] :post [(= % (* 2 x))]} (f x)) => #'enhanced-hickory.core/constrained-fn ((try (constrained-fn #(* 3 %) 2) (catch Exception e (.printStackTrace e)))) java.lang.AssertionError: Assert failed: (= % (* 2 x))

noisesmith19:05:52

there’s extra parens around that try…

markbastian19:05:09

(try (constrained-fn #(* 3 %) 2) (catch Throwable e (.printStackTrace e))) => nil java.lang.AssertionError: Assert failed: (= % (* 2 x)) at enhanced_hickory.core$constrained_fn.invokeStatic(form-init6196173666840420140.clj:1) at enhanced_hickory.core$constrained_fn.invoke(form-init6196173666840420140.clj:1) at enhanced_hickory.core$eval15641.invokeStatic(form-init6196173666840420140.clj:2) at enhanced_hickory.core$eval15641.invoke(form-init6196173666840420140.clj:1) at clojure.lang.Compiler.eval(Compiler.java:6978) at clojure.lang.Compiler.eval(Compiler.java:6941) at clojure.core$eval.invokeStatic(core.clj:3187) at clojure.core$eval.invoke(core.clj:3183) at clojure.main$repl$read_eval_print__9983$fn__9986.invoke(main.clj:242) at clojure.main$repl$read_eval_print__9983.invoke(main.clj:242) at clojure.main$repl$fn__9992.invoke(main.clj:260) at clojure.main$repl.invokeStatic(main.clj:260) at clojure.main$repl.doInvoke(main.clj:176) at clojure.lang.RestFn.invoke(RestFn.java:1523) at clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__996.invoke(interruptible_eval.clj:87) at clojure.lang.AFn.applyToHelper(AFn.java:152) at clojure.lang.AFn.applyTo(AFn.java:144) at clojure.core$apply.invokeStatic(core.clj:657) at clojure.core$with_bindings_STAR_.invokeStatic(core.clj:1963) at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1963) at clojure.lang.RestFn.invoke(RestFn.java:425) at clojure.tools.nrepl.middleware.interruptible_eval$evaluate.invokeStatic(interruptible_eval.clj:85) at clojure.tools.nrepl.middleware.interruptible_eval$evaluate.invoke(interruptible_eval.clj:55) at clojure.tools.nrepl.middleware.interruptible_eval$interruptible_eval$fn__1041$fn__1044.invoke(interruptible_eval.clj:222) at clojure.tools.nrepl.middleware.interruptible_eval$run_next$fn__1036.invoke(interruptible_eval.clj:190) at clojure.lang.AFn.run(AFn.java:22) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

noisesmith19:05:13

and an assertion error is not an exception

markbastian19:05:14

sorry for the span

markbastian19:05:22

yeah, needed to catch the Throwable

markbastian19:05:31

not Exception

markbastian19:05:15

so to get usable info from pre/post I need to wrap it in a try/catch somewhere? That seems to be the answer.

noisesmith19:05:19

enhanced_hickory.core$constrained_fn - that’s your namespace and function, right at the top

dpsutton19:05:22

> It'd be nice if it told you the function or ns where it occurred.

dpsutton19:05:29

Assert failed: (= % (* 2 x))

dpsutton19:05:35

at enhanced_hickory.core$constrained_fn.invokeStatic(

markbastian19:05:22

Yeah, what I was hoping for was a better message without wrapping the call.

markbastian19:05:22

(constrained-fn #(* 3 %) 2) java.lang.AssertionError: Assert failed: (= % (* 2 x))

noisesmith19:05:26

also, with assert (as opposed to :pre and :post) you can provide a string describing the issue

noisesmith19:05:52

AssertionErrors are meant for catching things during development, I would skip the try/catch and use the file / line info from the stack trace to see which code I need to fix

dpsutton19:05:07

Do you not have some version of this?

dpsutton19:05:51

this uncaught assertion error has a stack trace

markbastian19:05:52

I'm in the cursive repl.

markbastian19:05:01

w/o the try/catch all I see is this:

markbastian19:05:11

(constrained-fn #(* 3 %) 2) java.lang.AssertionError: Assert failed: (= % (* 2 x))

dpsutton19:05:13

ah. i'm surprised

dpsutton19:05:26

and it tells you the function which failed the assertion?

markbastian19:05:35

no, it just dumps the assert

noisesmith19:05:57

@markbastian if that’s all you see, clojure.repl/pst will show the whole trace

markbastian19:05:06

Yeah, that's my whole issue. I was expecting better reporting (the whoe stack trace)

noisesmith19:05:10

usually clojure.repl is in scope so you can just run (pst)

noisesmith19:05:37

when in doubt, (use ‘clojure.repl) is a good idea when developing after switching namespaces

dpsutton19:05:04

can you post a screenshot?

dpsutton19:05:29

in lein repl i get at least the function that fails the constraint even though i don't get a stack trace

markbastian19:05:39

ah, that's cool

markbastian19:05:01

So, pst def solves the problem for now. Thanks!

noisesmith20:05:33

yeah- assertion errors and pre / post are mainly for dev time, it’s totally legit to turn off assertions in production

noisesmith20:05:00

if you get an uncaught error in an app, you should get a stack trace unless someone is over-eager with a try/catch

dpsutton20:05:41

i wonder if there's a setting you could set or maybe they could update that. you could try #cursive

wiseman20:05:13

yeah, this seems like a cursive issue more than anything.

mobileink20:05:35

Proposal: "The Clojure community should dump slack in favor of something to be named later." Please respond by selecting one of the following, where 🐓 means "dunno", or "undecided" or "no opinion". 👍 👎 🐓

lincpa00:05:29

mobileink: is 👍 means stay on slack? is:-1: meas don't stay on slack?

mobileink00:05:55

no. just the opposite. Yes means “dump slack” etc.

mobileink20:05:21

motivation: this comes up sometimes. let's get something approximating real data.

dpsutton20:05:34

well looks by a vote of 0-1 we'll stay on slack

mobileink20:05:59

hahaha! wait, you didn't vote! seriously, low response rate (let's give it 24 hrs) means it is not perceived as an issue. which would be good to know since clearly some do think its an issue.

mobileink20:05:05

late friday was probably not the best timing. 😉

mobileink20:05:29

ok just ate my doggiefood. what about you? heh.

mobileink21:05:26

my guess is most of us just haven't even thought about it, and probably don't much care. but you never know what real data might show.

john21:05:01

I got hung up on "to be named later"

qqq21:05:18

@mobileink : I just cast the deciding vote, takikng it from 2-2-1 to 2-3-1; get hacking, dude

john21:05:28

without valid arguments for something better, hard to commit

qqq21:05:03

the other problem is that with the 10k limit, and the inability to pin posts, few ppl will see mobileink's voting system before it vanishes

dpsutton21:05:36

if the poll disappears, I would vote to move off of slack. but i would be unable to vote in this case. Slack's limitations prevent me from complaining about slack's limitations

mobileink21:05:42

dpsutton: is that a beautiful business model or what!

mobileink21:05:42

@john: just wanted to gauge slack response. proposing a specific alternative would bias the tesult.

mobileink21:05:45

@qqq: methodologically, is it ok if we take all the people who did not see it before it vanished as "yes"?

qqq21:05:41

@mobileink : personally, I would be okay if you took all the people who voted 'no' and interpreted them as 'yes' 🙂

qqq21:05:11

I think if we had a better system, for wiki links . ;pinning stuff in discussion, people would also provide answers

mobileink21:05:18

dude, this is clojure, not php.

qqq21:05:38

right now, it's an "eh, wasted effort"; whereas if we knew that it had long term value, we would be more likely to write wiki like responses

qqq21:05:58

it'd also be useful to be able to answer questions by poiting at wiki docs instead of retyping ansers to repeat questions

mobileink21:05:39

yeah, hence the poll. you and me (and others) would like to see more, but if the vast majority of users are satisfied with what we have, it would be a waste of time to try to sell them on sth else.

qqq21:05:41

i think the way to bridge this is by writing a slackbot that (1) archives everything and (2) starts auto answering questions

mobileink21:05:50

plenty of lorem ipsum generators around.

dpsutton21:05:25

he's a log of today

mobileink21:05:17

better than nothing, i admit. but undeniably hackish. slack search does not talk to it akaik. and, frankly, i am far too lazy to go grubbing around the web to find old slack msgs.

richiardiandrea20:05:37

hswick: jumped right there as well, good job in putting that up (if it wasn't you, good job in sharing 😄) !

hswick21:05:28

It wasn't me. Someone named hagus, but thought I should share since jumping from slack was coming up. The discord group seems cool, I'm digging it

mobileink22:05:11

so far we have a response rate of 9 out of approximately 10,000. Hear me, O People! I am compelled to say that I am a little dissapointed by your lack of enthusiasm. Vote - use it or lose it, and be condemned to program in Java for the rest of your sorry life! heheh.

john22:05:48

ugh, did that have to call it "clojurians" again 😑

mobileink22:05:38

you got a better idea? sadly, i don't. "clojurites"? "clojacks"? "clojicians"?

noisesmith22:05:24

our local clojure meetup was “clojerks” for a while

noisesmith22:05:35

I first attended just so I could say I was an official clojerk

noisesmith22:05:28

it’s “clojure pdx” now, but seattle’s was still called seajure last I heard

mobileink22:05:52

but how to pronounce the "j"? hard or soft? perhaps that could be our shibboleth.

john22:05:25

@mobileink I think it was extensively debated before and "clojurians" won, so I probably shouldn't complain

mobileink22:05:42

oh, i like seajure (seizure?)

notid23:05:16

Are there any projects like skummet (which seems unmaintained) that create emit AOT-compiled clojure that can be tree-shaken?

notid23:05:18

I’m trying to get my binary size down. There are a ton of unused classes in my jar.