Fork me on GitHub

Good morn


Last day of vacation. Thinking about going to sleep.


Sleep is always a good idea


Is today plough Monday? Or was it the 6th?


Morning 😄 I've been back at work a week and I'm still thinking about going back to sleep


2/3 links I checked say today is plough Monday... That means it's time to go back to work slackers (pun unintentional, but not avoided)


Day 1 of holiday….. Planning a talk, a proposal to put in and figure out some streaming stuff.


Morning all!

Wes Hall11:01:36

Sorry, I do try not to get too much into politics / current events on this channel, but this made me literally "lol", and I thought I would share the mirth on a cold monday morning.

😂 16

I don't think that counts as politics, does it 😛


Say I wanted needed to make a private field accessible using Clojure (a java class, interop stuff), any examples?


(defn private-field [obj fn-name-string]
  (let [m (.. obj getClass (getDeclaredField fn-name-string))]
    (. m (setAccessible true))
    (. m (get obj))))


but keep in mind security policies can prevent this (if you ever want it deployed at a customer site you don’t control)


trying it out


works wooooonderfully 🙂


Nice. Pretty common Javaism.

Wes Hall13:01:41

Yeah, I used to do a magic trick where i'd use this to alter the state of an interned string value, so that you could write, System.out.println("HELLO"); and it would print "GOODBYE". It was quite fun.

Wes Hall13:01:58

...for certain definitions of "fun"

😂 4

I didn't consider using the standard java paradigm in doing this - I was looking at clojure.reflect etc..


and trying to see if that would work


perhaps my head is too much in clojure world 🙂


Would anyone be interested in volunteering to be a coach for ClojureBridge London this February? Details are here:

Rachel Westmacott12:01:25

interested but dates aren't ideal. the page suggests that you already have more coaches than coachees? do you still want more?


Hey! Thank you for your interest! I think we are good for this February but I'm happy you considered being a coach


Maybe next time?

Rachel Westmacott13:01:30

It's been on my todo list for a while, but if there's no shortage of coaches then that's great!

Rachel Westmacott13:01:10

(tangentially, the date formats on that website you linked are quite hard to read)


Ping me via DM if so 🙂


does anyone use a separate namespace just for keywords relating to a particular component, so that it's safe to :require from anywhere and get namespace aliases without circular deps ?

Wes Hall18:01:29

@mccraigmccraig I am not sure I 100% understand the question, so I guess I don't. Sounds intriguing though.


just this... if you have a component with some interface fns or whatever defined in foo.thing , you might want to to use :foo.thing/whatsit namespaced keywords with it... over time, if your implementation expands and you get a foo.thing.implnamespace, if that gets required by foo.thing then it can't require [foo.thing :as t]to get namespace alised keywords like ::t/whatsit because there would then be a circular dependency


one solution is to never use aliases for namespaced keywords in implementations, another would be to use a namespace just for keywords like : so you can require [ :as t] and use ::t/whatsit


maybe i'm just being thick and there are other possibilities too

Wes Hall18:01:16

@mccraigmccraig Yeah, I see what you mean. I don't do this. I think for a couple of reasons of personal principal and a couple of reasons of personal ignorance. An example of the latter is that I am not even sure I knew / realised that "requiring as" and then using the alias for the namespace keyword was even a thing. Something I would probably have expected to work, but probably wouldn't think about. On principal though, I think having foo.thing require foo.thing.impl would register as a smell to me because I don't really like a "general" namespace knowing about a "specific" one in this way. If all this stuff got too awkward I think my tendency would probably be to just put everything in foo.thing, because I am developing a view that large clojure namespaces are not too much of a problem and I am trying to resist my old urges to break everything up. clojure.core is pretty big, and that seems to be fine, so I might question why I would need the seperate impl namespace in the first place and merge it all back in... but I thinking aloud here.

Wes Hall18:01:58

Makes me wonder if there is a way to alias a namespace without requiring it

Wes Hall18:01:07

Namespaces for keywords and required namespaces are really different things.


no, you can't alias a namespace without requiring it afaict, although the namespace for a keyword doesn't need to exist at all - but it does if you want to alias it

Wes Hall18:01:54

Can you not just do (alias 't 'foo.thing)

Wes Hall18:01:04

Never tried anything like that, we're in crazy town 🙂


this is mostly coming from a re-frame app - there's no alias in clojurescript

Wes Hall18:01:20

Ahh, fair enough.

Wes Hall18:01:00

It's a bit weird really because you are not at all needing to "read" the code in foo.thing there, you just want a short hand. You get the short hand by reading it, but you want the effect and not the cause.


and it's re-frame standard layout to split event-handlers, subs and views and db stuff relating to the same component into separate namespaces


yeah... we mostly have used keywords with namespaces which don't relate to a "real" namespace at all, but that brings another problem - sanitising the ns declarations for re-frame components which refer to the subs and event-handlers of such components will remove the requireclauses, because there's never any direct reference to a thing in the namespace


hence looking at using keywords which refer to real namespace, so we would use re-frame event handlers or subs name :foo.thing/whatsit etc

Wes Hall18:01:49

It does raise the interesting question about whether the re-frame standard layout is sensible. It's one of those "two dimensional hierarchy" problems, where you want to separate based on both component and function area. I am pretty sure I explored breaking from this convention in previous re-frame experiments and allowing myself to define the views, handlers, subs etc for a single component in a single namespace... at least where they were component specific. I am pretty sure I had a "core" namespace that defined subs etc that are used in various places (user etc), but I was just toying around.


we've done both - some of our older code has everything in a single namespace, but it sure gets unwieldy and hard to navigate after a while

Wes Hall18:01:38

Probably easiest solution is just to type the whole namespace for the keywords. Just avoid the problem of having to require the ns at all. Little extra typing, but problem disappears.


also, one re-frame ns is harder to test - subs and event-handlers don't need any react related stuff, so we can run their tests on node or even clj/jvm, but only if they are separated from the views code


yeah, you are probably right (use longform keywords)

Wes Hall18:01:18

Aren't views just returning plain vectors outside of react context?


oh, hmm, maybe i'm confused... maybe it's ok on node, and it's just .cljc on jvm that's a problem


I'm surprised cljs doesn't have alias... I wonder why not?


alias doesn't have anything to do with Vars tho'...


In Clojure we use (alias 'foo (create-ns ' and I see that create-ns works in cljs... alias is like require ... :as so it seems a strange omission.


(but if I've learned anything about cljs over the years, it's that it has lots of small, sometimes strange, differences from clj)


i guess at some point in history it didn't make much sense to provide alias if there was nothing for you to refer to with an aliased reference