Fork me on GitHub
#clojure
<
2018-02-11
>
schmee00:02:02

can you disassemble an inner class with no.disassemble?

schmee00:02:40

usually I just do (disassemble (Foo.)), but (disassemble (Foo$Bar.)) doesn’t seem to work

bronsa00:02:42

inner classes don't exist at the jvm level

bronsa00:02:09

@schmee define doesn't work

bronsa00:02:37

at the bytecode/jvm level a java inner class is nothing different than a regular class, with an $ in the name

schmee00:02:38

well, I get an empty string

bronsa00:02:00

¯\(ツ)

bronsa00:02:12

I don't know how to help with that but I wouldn't focus on it being an inner class

schmee00:02:18

aight, I’ll dig around some more

bronsa00:02:57

it might be that there's some bug in no.disassemble

gganley03:02:18

So I’m quite sure this is not in the standard library but I’m trying to write a function that takes the output of partition and combines the overlapping parts with a function

gganley03:02:31

so for example I have (partition 1024 768 (repeat 0) coll) and I want to combine the overlaping partitions with *

noisesmith03:02:54

so you want to reduce each partitioned list to a numeric value?

noisesmith03:02:05

or do you mean something else by "overlapping"

gganley03:02:17

wait let me get my ipad, I’ll draw out what I mean

gganley03:02:45

Is the image visible or do I have to host it on some other image service

noisesmith03:02:21

that's visible

noisesmith03:02:57

seems like you have to take the partitioned input, then make your "un-partition" by counting the items in the first element

noisesmith03:02:23

no, wait, you need to know the second arg to partition I think

gganley05:02:23

You would have to know the “overlap rate” do to speak

noisesmith05:02:26

oh, right, the first and second arg are needed for that

qqq05:02:39

My current setup for providing https:// and wss:// is: 1. provide http:// and ws:// via clojure http-kit/ring 2. use some node.js wrapper to do magic with *.pem, open up https:// and wss:// and redirect to clojure's http:// and ws:// question: is there a nice way to do https/wss directly in clojure? I have all the certificates/private keys, I just need the webserver to do the encryption stuff

spinningarrow06:02:59

I'm running some Clojure code that counts the number of words in a wikipedia dump. When I run it with lots of pages (500+) get a NullPointerException [trace missing]. How can I debug this further?

spinningarrow06:02:38

Never mind; manually dug into the code and found that one of the seqs was nil

gklijs07:02:47

@qqq there is https://github.com/nginx-clojure/nginx-clojure which should allow to use the nginx way of doing, and should also give you http2 easily. Still have to try for myself, no priority so far.

fmnoise17:02:28

12001 user here 🎉

yogidevbear18:02:06

12308 in #admin-announcements simple_smile

dpsutton18:02:14

there was a question in #cider about how to turn off the prepended namespace from maps with namespaced keys like

clj -e "{:a/a 1 :a/b 2}"
#:a{:a 1, :b 2}
does this option exist?

noisesmith18:02:11

user=> (clojure.repl/doc *print-namespace-maps*)
-------------------------
clojure.core/*print-namespace-maps*
  *print-namespace-maps* controls whether the printer will print
  namespace map literal syntax. It defaults to false, but the REPL binds
  to true.
nil

schmee21:02:01

can I def a primitive byte?

schmee21:02:16

(def ^byte ^:const ubyte (byte 0x01)) doesn’t seem to work when I look at the bytecode

noisesmith21:02:48

a def can't hold a primitive

bronsa21:02:00

clojure doesn't really support primitives other than long and double that well

noisesmith21:02:19

even a primitive long can't go in a def though, right?

bronsa21:02:46

not in a def

bronsa21:02:51

but if the def is const

bronsa21:02:00

then a primitive long will be inlined at the usage sites

bronsa21:02:52

so technically the def would hold a Long, but usages of that var compatible with primitive values would only see an inlined primitive long

bronsa21:02:41

I find it quite annoying how clojure ignores the existence of primitives other than long and double

bronsa21:02:44

for no good reason IMO

noisesmith21:02:08

combinatorial explosion of IFn method signitures

schmee21:02:16

is it a some sort of fundamental limitation or just priorities?

bronsa21:02:16

no that's not what I'm talking about

bronsa21:02:40

@noisesmith I understand the rationale for supporting only long/double as primitive function arguments

bronsa21:02:57

but clojure doesn't really deal well with other primitive in contexts where there's no technical limitation for it

bronsa21:02:10

@schmee no fundamenal limitation

bronsa21:02:33

just a lack of interest in supporting it from what I can tell

bronsa21:02:24

I've made a few patches enhancing support but they've been rotting in jira for a while so it's clear that there's not a great deal of interest about it

schmee21:02:51

link them and I’ll give ’em a vote 🙂

schmee21:02:58

so, if I have a byte[] and want to do a bunch of stuff with it, I guess I’m better off using long[] in Clojure and shed a tear for all my wasted bits?

bronsa21:02:51

jira's search sucks, there's others but I don't want to spend my time looking tbh

bronsa21:02:58

@schmee well, depends

bronsa21:02:25

if you stay in a local scope, primitives other than longs and doubles are somewhat supported

bronsa21:02:35

as long as you don't escape a fn context or loop or...

bronsa21:02:53

pick your poison

noisesmith21:02:59

@schmee an array of byte still works - it's just standalone unboxed bytes that have this issue

bronsa21:02:26

it's the "doing a bunch of stuff with it" part that might be a problem

noisesmith21:02:51

oh, right, of course

noisesmith21:02:30

but you can stil use an array of byte - worst case converting to long, but in the local scope it might even do the right thing

schmee21:02:51

yeah, just to give some context, I wrote a board game thing in Clojure, and just to see how fast it could go I wrote another implementation in Java that uses bitboards

schmee21:02:16

now I want to see how closely I can emulate the Java bitboard version in pure Clojure

bronsa21:02:45

@noisesmith eh, clojure will sometimes do weird stuff

bronsa21:02:22

like byte -> Byte -> long

schmee21:02:46

yeah, if you’re using native bytes, you’re doing it because you want something to be predictably fast

schmee21:02:12

if something gets auto-boxed in any place everything just goes down the toilet

bronsa21:02:22

but by all means, you should try and see for yourself

bronsa21:02:37

it's possible that for your usage you'll get the right unboxed behaviour

bronsa21:02:52

just beware

schmee21:02:23

yeah, thanks for the advice

schmee21:02:52

it would be cool if the compiler had some additional support for primitives, that would mean that I could use Clojure to replace Java even for the low-level stuff 🙂

noisesmith21:02:56

@schmee I forget - did you mention using no.disassemble?

schmee21:02:38

nope, but I do and it’s indispensable 🙂

bronsa21:02:54

I'm still an old dinousaur and compile my stuff and decompile it using java c p

schmee21:02:01

it’s a fools errand to do primitives in Clojure without it 🙂

bronsa21:02:10

well, I have an emacs mode that does it JIT when I open aclassfile

schmee21:02:12

or javap, of course

bronsa21:02:20

but I shoud start using no.disassemble

noisesmith21:02:28

@schmee sometimes I fear that that sentence could end at "Clojure"

bronsa21:02:33

I don't remember 100% anymore but I believe I made t.e.jvm work with all primitive types as you'd expect

schmee22:02:16

@noisesmith speaking of combinatorial explosions, I just looked at the IFn interface… that’s not something you see in Java everyday 😄

qqq22:02:07

is there really no builtin for: (def atom? (fn [obj] (instance? #?(:clj clojure.lang.Atom :cljs cljs.core.Atom) obj))) ?