Fork me on GitHub
#clojure
<
2018-06-14
>
hagmonk02:06:02

anyone seen core.match return "method code too large" when you get up around 6 patterns?

dpsutton02:06:20

macros that write a lot of code can do that. the jvm only allows method bodies to be so large and the match macro can expand to be too large

👍 4
hagmonk03:06:57

@dpsutton I refactored it into a couple of functions and now things are happy

Alex Miller (Clojure team)03:06:41

there’s a ticket about this

minikomi04:06:53

crouton + spectre for parsing & pulling values out of html is working very nicely for a quick scraping job I had. Once the dom is in a regular clojure data structure it's super easy to write functions to access the data.

roklenarcic08:06:39

I used enlive for html parsing and scraping

roklenarcic08:06:49

Also works for templating

emil0r09:06:35

@hagmonk I’ve had matches up to 7 patterns

kennytilton10:06:27

@dpsutton “the jvm only allows method bodies to be so large”. Heh-heh, the JVM blind-sided by macros? Gosling/Steele failed to anticipate Mr. Hickey.

ikitommi13:06:13

I have a protocol function with 2 arities (2 & 3). Is there a way to add an extra arity (4) with common body to all implementations? I could do this easily with a separate function with different name, supporting 2,3 & 4 arities, but would like to know is there another way.

ikitommi13:06:36

ok, thanks.

lwhorton16:06:31

hmm .. what’s the most clear way to say “this map will have 1 of 2 types of keys, give me one of those 2 keys” .. like I could do (first (keys (:select-keys map [:foo :bar]))) which would give me :foo or :bar but it’s kind of icky

lwhorton16:06:04

(huh i can’t seem to edit that above to fix :select-keys and clarify with the-map)

dpsutton16:06:20

(get thing :foo (get thing :bar ::not-found))?

dpsutton16:06:42

or (:foo thing (:bar thing ::not-found))

Eddie16:06:03

Curious if anyone has any thoughts on this thread about figuring out which Clojure core functions rely on which protocols/interfaces. Been stumping me for months, and it makes designing new data structures a challenge for me. See the original thread for full conversation.

hiredman16:06:07

(key (or (find m :foo) (find m :bar)))

lwhorton16:06:17

☝️ gracias

Alex16:06:20

My experience is: In clojure most of the core types are not implemented with protocols but instead with the clojure jvm types and their interfaces in https://github.com/clojure/clojure/tree/master/src/jvm/clojure/lang In ClojureScript there are protocols that mirror the core interfaces you need to implement starting at https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/core.cljs#L532

hiredman16:06:48

https://gist.github.com/semperos/3835392 has been making the rounds recently

👍 8
hiredman16:06:56

but in order to use that, you have to know the java interfaces you want to extend, and the only way to find that is often to look at the source of the function you want to work on your collection, then find the method in RT that function calls

spieden18:06:56

is there any way to splice a value into a quoted form? e.g.

'{:find [(pull ?e ~reusable-pull)]} -> '{:find [(pull ?e [:my-pull])]} ; ?
; this instead evaluates to:
'{:find [(pull ?e [(clojure.core/unquote reusable-pull)])]}

hiredman18:06:47

no, you have to use syntax quote

spieden18:06:10

.. which then would namespace qualify ?e?

hiredman18:06:20

you can use ~'pull to avoid ns qualifying pull, similar for ?e

spieden18:06:28

ah ok, thanks

spieden18:06:47

might just assemble instead

hiredman18:06:33

there are also some libraries that provide something like syntax quote, but more customizable

spieden18:06:55

ah wow, fancy

metacritical19:06:52

Does someone know why was clojure.contrib deprecated from clojure?

Alex Miller (Clojure team)19:06:04

have a lot of the background

josh_tackett22:06:49

Anyone know a good example of an implementation of https://github.com/metosin/reitit ?

danielglauser22:06:12

@josh_tackett You may want to ask this in #reitit.

waffletower23:06:03

Is there a simpler way to achieve this that I may be forgetting?

(defmacro compile-time-eval [form]
        (eval form))

noisesmith23:06:19

you can just put form in a def or a top level let and get the same result

waffletower23:06:35

you’d need to name it then 🙂

waffletower23:06:02

it’s intended for single use inline evaluation

ghadi23:06:19

I kind of need to know the context to avoid the xy problem but syntax-quote is typically used in a macro

waffletower23:06:43

The intent is to allow a def like form that is used only once to be directly placed in its single use code context.

ghadi23:06:35

Can you give an example?

ghadi23:06:38

Sounds a bit like symbol-macrolet...I'd love to understand more!

waffletower23:06:26

will post in a bit

waffletower23:06:30

thanks for looking at it

noisesmith23:06:46

wouldn't that eval be different as it would return the code to be compiled rather than the item? unless what it returns is always self-evaluating of course

noisesmith23:06:10

I could be missing something

tdavis23:06:29

has anybody experienced problems with Class/forName not finding classes when used by dependent code? i have a ns that imports a class successfully, i can even use Class/forName to fetch it again from that ns. but during a test run, when the same function is used by a third-party library to load the same class, it fails with ClassNotFoundException. it doesn't appear that the library is using its own classpath loader.

hiredman23:06:50

is the class defined in clojure? (a protocol interface or deftype, defrecord)

tdavis23:06:48

no, it's a java class

tdavis23:06:36

and defined in the same project trying to find it, ironically