Fork me on GitHub

but I do still seem to be making progress, thanks @hlolli


@mathpunk That should be (:require ["fs" :as fs]) (`:as` should be a keyword)


hey thanks to all y'all helping me out, I now have a little web service that can generate extremely useful data, such as "Gandalf's music box of crafty second chances" and "an orcish sweater of courage" 😄


another one that made me laugh was "Castamir the Usurper's mantle of ubiquitous second chances"


My issue is getting the bindings to resolve to the correct cljs vars


when using my list version


wait im silly, I figured it out doing way more than I need to be lol


Can I use ClojureScript with React with Lumo compiler?


How can I attach code snippet to Slack? )


How does one alias a macro from namespace A to be used from different namespace B as though it were part of namespace B?


@benzap (... :require [ :refer-macros [your-macro]])


there's also :require-macros with :refer


no no, I mean say I have a macro in namespace A called, and I create a new namespace B. I want to make an alias of, within namespace B such that will refer to


so when I call (:require [B :refer [foo]]), it will refer to, which in turn is an alias for


afaik best you can do is define a macro foo in B which calls


I should write some sort of macro to make macro aliases lol


hmm, it doesn't appear to like the macros, does it matter that i'm writing the macros in a .cljc file without reader conditionals?


@benzap (ns my.lib (:require-macros [my.lib])) this lets anyone use my.lib/foo directly whether its a macro or a fn


so (:require [my.lib :refer (foo)]) is probably prefereed over (def foo ...) in the ns itself?


@thheller I think he'd like some potemkin-like import feature


The problem is I don't want them to use it directly, i'll be more specific, I want to wrap a logging library into shortforms which can be refered to from a local namespace


ah. you can delegate but CLJS itself doesn't have anything for aliasing built-in


ie. I want to refer to taoensso.timbre/info from foo.log --> (require '[foo.log :as log]) (log/i "test") ;; (taoensso.timbre/info "test")


ya, i'm having troubles with the cljs side, clj seems to work, here's what I have: (defmacro i [& args] {tilde}(taoensso.timbre/info [email protected]))


on the cljs side, calling (log/i "Test") --> (taoensso.timbre/info)


do you have (ns foo.log (:require-macros [foo.log]))?


add #?(:cljs (:require-macros [hsynapse.log]))


to where it's called?


first thing after (ns hsynapse.log #?(:cljs (:require-macros [hsynapse.log])) ...)


Doesn't appear to make a difference 😞


I think the later clojurescript versions don't need you to use :require-macros, they figured out how to infer it


the client has (:require [hsynapse.log :as log]) (log/i ...)?


here, i'll post the whole file, so you get an idea


so i'm calling (:require [hsynapse.log :as log]) ... (log/enable-logging!)


#?(:cljs (:require-macros [hsynapse.log :refer (i)]))


oh interesting, that works


.cljc files are basically 2 files in one


the defmacro should probably all be in :clj conditionals


so does this mean I can't refer to an aliased namespace macro?


or rather just split it into a .clj and .cljs files to begin with 😛


haha yeah, I was testing my hand at reader conditionals


I might just split them out then


its hard to keep track of what is CLJS and what is CLJ sometimes in those files but basically the CLJS version didn't know what i was so it failed


so from what I can tell, is there no way to shortform the namespace for i?


it gets much easier to understand what is going on if you split the files into .clj and .cljs


reader conditionals just make it super confusing


ah, I think I figured it out


yeah, I see what you mean. so i'm calling :require-macros to drag the defmacro from the :clj conditional


so it's self-referencing it's macro half


yeah, I should probably split this up into separate files


@benzap Yeah, keeping things separate is better IMHO, but if you really want to cram everything into one file, there is a library that helps with this:

Jacob Haag13:02:53

Hey everyone, my name is Jacob and I have been given the task to test our Clojurescript applications. Currently, we are using "Doo" as our test runner and "Phantom JS" as our environment. One thing I have not been able to find a solution to is how to report our test results (other than just in the cmd). I know there are certain libraries available for formatting test results into JUnit test results but I have not been able to find any that integrate well with the "Doo" runner and "Phantom JS" environment. We would like to avoid using Karma and stick to Phantom JS. Does anybody have any recommendations for a solution to report clojurescript test findings?


is there a difference between ClojurScript and CLJC? in this talk is told that with Foam you have to port all ClojureScript to CLJS :thinking_face:


cljc files just allow you to have clojure specific and clojurescript specific code in one file. There's a reader macro that let's you say "if this code is run in clojure, use this" and the same for clojurescript, other than that, cljc is the same as cljs


It's just a way to store CLJ and CLJS in one file with some special switches. (I apologise if I misunderstood your question though!)


Kind of, I use it in one project to be able to use the same specs for client and server site rendering


But the goal should not be to put everything in cljc, just the bits you want to use on both sides, so in my case there are also a lot of functions taking specced data and giving back hiccup-like data structures of the components


but not much else


terminals are notorious so its tough to move ahead without a decent number of folks reporting success


if you find something please report it, and include terminal/platform info


Working beautifully in a fresh lein new figwheel.... I'm on Arch running Termite. awesome work, can't wait to integrate rebel-repl in more places! Massive jump for usability.


Now get it working in Chrome devtools 😜


looks like it's working for me on centos 7 running alacritty


I’m sure I’m not the first, but it seems to be working great in iTerm2 on macOS. I did find one interesting issue with apropos:


dev:cljs.user=> (re-find
java.lang.ArithmeticException: Divide by zero
	at clojure.lang.Numbers.divide(
	at clojure.lang.Numbers.divide(
	at rebel_readline.clojure.line_reader$standard_deviation.invokeStatic(line_reader.clj:619)
	at rebel_readline.clojure.line_reader$standard_deviation.invoke(line_reader.clj:613)
	at rebel_readline.clojure.line_reader$two_standards_plus_mean.invokeStatic(line_reader.clj:625)


(that was from hitting C-x C-a at the end of re-find, which presumably has nothing for apropos to find)


that's a good one


@bhauman working on a small re-frame leiningen project, only had to set the snapshot version


great I'm assuming its working then, thanks!!


holy eff, sherman has its first user other than myself! She too wants to generate text like "Tar Meneldur's blast of non-euclidean sparks"... but, she's not a Clojure user, so I'm trying to compile a server.js file to put in a dist directory. So far no luck. Here are my project.clj and my build.cljs files---


but i'm not using the --classpath right, i don't think, because while i compiled something, it throws on running it with node, because it can't find transit


oh! i have another problem, where, when I run my program I get errors that it's never heard of the namespace clojure.string, and yet, the functions that rely on it seem to be doing their work. super weird~


@mathpunk What you are probably seeing is that, in the namespace you are working with, you are calling functions in clojure.string without having required it. This causes the analyzer to complain with some warnings. But, they are just warnings, and the code that gets emitted happens to be correct. And at some point, something did require clojure.string, so the actual functionality is present in JavaScript.


Ohhhh yeah that makes sense. In Clojure I've frequently found myself using a single string function once, so I just fully qualify it


Yeah, simply calling (clojure.string/trimr "abc ") is insufficient. Even though it might work, you really need to ensure that clojure.string is required in the namespace you are in.


this can backfire when using namespaces (including clojure.string itself) that might be loaded by your tooling but not required in a direct invocation of your jar


there’s minimal extra cost to requiring a namespace everywhere you use it, and it avoids these gotchas


Yeah, in other words, requiring a namespace essentially mutates the environment. But correct code puts all of its requried namespaces in its ns, form (for lack of a better way of putting it). One way this can bite you is, for example, if you enable parallel compilation in ClojureScript, and by chance, your namespace that is using clojure.string gets compiled first.


On this subject, @mathpunk there is an interesting compiler option, :analyze-path. This post might be informative and help understand this particular issue a little better:


I'm glad I have learned this before getting bitten by it, because (as I've made clear in #beginners) my mental model on what abstractions belong in the language, the runtime, and the tooling is fairly fuzzy


I think that’s normal actually. 80% of the features people think come from their tools come from the language, and 90% of what people think comes from the language comes from the runtime. To make a wild estimate.


67% of @U051SS2EU’s statistics are made up on the spot 😛


I recall this subject coming up before with Alex Miller too. I was curious on the “reliability” of using some clojure/core namespaces that just happen to be pe-required on Clojure startup. If I recall correctly, he said that they are not something you should rely on. This is just reiterating what others have already said on this thread though. One relevant example that comes to mind is, eg. if Clojure was tweaked to speed up start-up time. It may be the case it “accidentally” requires a namespace right now that isn’t needed to startup. If it later removes that implicit require, your code may be broken if it relied on “some other namespace” to require the namespace for you. This same principle also applies to if you are implicitly getting a namespace loaded transitively by some library you depend on. That is an impl detail of that lib and could change and break you later. The whole subject reminds me of Maven (and probably other tools) best practice of not relying on transitive dependencies.


iirc the only one that won’t ever be absent is but even that could be missing in some future version, and adding a require for something is basically free, so…


IIRC, the same thing that occurs in ClojureScript is that goog.object, goog.string, and goog.array are always loaded, but strictly speaking, you shouldn't rely on this.


Perhaps the only things you can rely on are clojure.core and cljs.core 🙂


Sounds right


There is any available linter/tool to check these kind of problem?