Fork me on GitHub
#clojurescript
<
2015-11-10
>
arohner00:11:20

@bensu I’m looking to load another .js that is on the page. I guess I can just use DOM methods

arohner00:11:26

document.createElement() etc

bensu00:11:31

@arohner: can you add it as a foreign lib?

arohner00:11:40

Not really. This is a .js file that other users will load in a normal <script src=“”>, so I’d like to test that behavior

arohner00:11:51

@bensu while you’re here, I’m also seeing 404: /js/cljs_deps.js. I assume that’s something to do with :asset-path, but I’m not sure what value it should be

mocker00:11:20

What libraries should I look at to build a client/server where multiple clients will be displaying a page, and then from a ‘control’ page can tell one of the clients to display a different page? Based off searching I’m thinking maybe sente for communication between client and server?

bensu00:11:49

the js/cljs_deps.js is a harmless warning

bensu00:11:13

I'm trying to figure out how to remove it, but I should document that in the meanwhile

bensu00:11:49

ok, so you are testing a library that expects the user to add scripts

bensu00:11:59

let me think about it and get back to you. I'm not sure how to do that (and I have to go to bed now)

arohner00:11:12

no worries. thanks

asolovyov08:11:41

what's the best way to run tests now? I'm using figwheel, can this help somehow?

pandeiro10:11:52

is sublime text 2 clojurescript support still decent? like, paredit/indentation at least?

martinklepsch10:11:16

@asolovyov: something using doo is probably what you want (lein-doo is a thing :))

asolovyov10:11:06

@martinklepsch: I made a setup where figwheel runs my tests on reload, will see how it works simple_smile

asolovyov10:11:15

don't want to have another process

aleksander11:11:13

I'm running Clojurescript repl on Node. Should I be able to require libraries using (:require '[ :as]) ?

aleksander11:11:00

I keep getting "Use of undeclared Var" messages and not sure if this is something expected

martinklepsch12:11:03

@aleksander: this is a warning telling you that there’s a var somewhere that hasn’t been declared previously

aleksander12:11:59

The problem in that case was (:require instead of (require. I mix it up all the time 😓 Also managed to require one lib in the repl so I now know its possible simple_smile Thanks for the answer!

dnolen12:11:08

@jensontech: error comes from that rethinkdb file I would try again without that dependency.

aleksander12:11:05

@martinklepsch: yeah, probably should still have it printed out somewhere nearby all the time

aleksander15:11:55

Is there a way to import one of the XMLHttpRequest "node polyfills" so that I can use ClojureScript libraries like cljs-http? Or should I go with the route of wrapping nodejs http? I've tried simply including them in the {:npm {:dependencies []}} and also (def XMLHttpRequest (node/require "name of polyfill")). In all cases i was still getting ReferenceError: XMLHttpRequest is not defined at [object Object].goog.net.DefaultXmlHttpFactory.createInstance (/Users/aleksander/projects/provider-poller/out/goog /net/xmlhttp.js:176:16)

ricardo15:11:18

Greetings. I’m a relative n00b when it comes to packaging and distributing ClojureScript libraries. I’m looking to merge khroma-tests and khroma, without shipping the khroma-tests dependencies when the library gets installed. This is the best way I can think of setting up the project: https://gist.github.com/ricardojmendez/7c196c2813785b05da89 Any comments or improvements?

ricardo15:11:48

I don’t want to have the devcards dependency on the main project, since it’s used solely for the tests. Having a separate profile seems like the best way to do that.

thheller15:11:23

@ricardo looks good, I generally use the :dev profile for this stuff

thheller15:11:47

but only because leiningen does include the :dev profile for some tasks automatically

thheller15:11:03

but the general idea of putting it into a profile is good

thheller15:11:47

eg. lein repl will include :dev while lein jar will not

thheller15:11:06

less with-profile calls 😉

ricardo15:11:46

Ah, right. In this case it’s best to leave it explicit, since the examples won’t even work on the repl anyway - you need to be running as an extension. Thanks @thheller!

thheller15:11:14

yeah but how do you call cljsbuild?

ricardo15:11:41

lein with-profile khroma-tests cljsbuild auto

ricardo15:11:04

(renaming from that file examples-> khroma-tests)

thheller15:11:11

yeah with :dev that would just be lein cljsbuild auto

thheller15:11:29

but if you are fine with with-profile that is perfectly fine to use

ricardo15:11:46

But then if they load it on a ClojureScript REPL, they’d have namespaces available that wouldn’t actually work.

thheller15:11:49

:dev just is convenient simple_smile

ricardo15:11:20

Indeed. I guess this is very much an edge case.

ricardo15:11:48

Thanks for the tip on :dev being included by default on those cases, though, I was wondering what was the rule.

thheller15:11:17

I think most tasks actually have a default profile they include

thheller15:11:36

eg. if you want something only to happen in uberjar put it in the :uberjar profile

ricardo15:11:44

Man, I’m such a pack rat. I have a hard time forgoing history for khroma-tests and just plunking the files into khroma… but the alternative is merging it with the parallel history up until now. That’ll result in an ugly commit tree.

thheller16:11:53

hehe I just force push over those thoughts ... no time for regrets 😉

denik16:11:54

is (volatile! nil) a js var? Or what’s the fastest mutable reference in cljs?

dnolen16:11:10

@denik atoms are pretty fast, fundamentally you’re just setting a field

mhuebert16:11:13

does cljs.js have a different way to enable/disable warnings from the normal compiler options (https://github.com/clojure/clojurescript/wiki/Compiler-Options#warnings)? adding :warnings {:undeclared-var false} to the options I pass to cljs.js/compile-str seems to have no effect.

denik16:11:31

@dnolen faster than volatile?

dnolen16:11:57

volatile is a Clojure thing, it just means no locking semantics

denik16:11:05

what is it in cljs

dnolen16:11:07

but we don’t have locks in ClojureScript anyway

denik16:11:13

b/c it’s implemented

dnolen16:11:29

volatile is just a box like atom

dnolen16:11:33

it’s there only for interop

dnolen16:11:39

no perf semantics worth talking about

denik16:11:47

so I thought, so they’re synonymous?

dnolen16:11:05

@mhuebert: might just be a bug

denik16:11:07

so single item array vs atom/volatile - which one is faster

dnolen16:11:15

@denik not synonymous

dnolen16:11:27

@denik questions like that don’t really make much sense

darwin16:11:33

atoms can have watches, volatiles not (I think)

dnolen16:11:36

because JS engines variance is significant here

dnolen16:11:57

if you’re really interested in what’s the fastest thing you can change

dnolen16:11:01

loop bindings

denik16:11:18

ah great, thanks!!

mhuebert16:11:39

@dnolen ok, thanks I will make a simple example.

mike17:11:40

is this comparison accurate about clojurescript?

tyler17:11:49

not sure how javascript interop is complicated in clojurescript @mike … I also think they are neglecting things like figwheel in their tooling comparison and hyper-focusing on IDEs

mike17:11:19

@tyler: what about safety? let's say I want to refactor my clojurescript code, how would it be easier than doing so in javascript?

tyler17:11:36

Type safety is definitely a limitation in clojurescript. The question is whether it provides you with any objective benefits in practice.

malch17:11:42

@mike: From my point of view, Scala.js code is safer while Clojurescript one is much more concise. Tried Scala.js too a while ago

mike17:11:42

@malch concise in what way? is scala.js too busy/verbose?

Tim17:11:42

what about elm? that is nice code

mike17:11:17

what about elm? how is it compared to clojurescript?

malch17:11:59

Never really tried elm, but heard great things about it

malch17:11:35

But you can reimplement Elm in clojurescript (to a point, of course)

malch17:11:00

Elm is type safe also (written in Haskell)

mike17:11:17

what do you mean by reimplementing elm? is it a language, or a library?

malch17:11:56

Like core.async was inspired by Go’s channels

dnolen17:11:22

@mike that grid is ridiculous

dnolen17:11:40

ClojureScript has IDE integration, and JS interop is first class

dnolen17:11:33

and the grid is of course missing more important things like maturity, adoption, deployments etc.

mike17:11:43

what IDE integration?

dnolen17:11:47

but that’s why you make grids

dnolen17:11:53

to pretend your thing is better

mike17:11:06

I found one for intellij, but it says it will not be free.

dnolen17:11:50

Cursive isn’t free but that’s a different dimension beyond IDE or not

dnolen17:11:21

people don’t really blink when IDE == commercial

dnolen17:11:38

as far as simple / fancy text editor integration, these things exist

malch17:11:28

@mike: I’m using CIDER (Emacs) for cljs programming. I’m probably one of the few, who tried Cursive, but came back 😄

mcgivernsa17:11:45

the worst part of the grid to my mind is that Scala.js gets green for 'Very good' interop; the same colour as ES6

dnolen17:11:30

to be clear Scala.js is super cool. That grid is not.

malch18:11:06

Right, knew about this one for a while, didn’t have time to try it though. @richiardiandrea Thank you for reminding 😊

richiardiandrea18:11:42

it is in my queue as well

roberto18:11:02

that grid is FUD. Tooling for cljs is awesome.

roberto18:11:17

oh, and Types alone != tooling

malch18:11:55

@mike That’s exactly the point I was making: https://github.com/jamesmacaulay/zelkova

jaen18:11:40

And well, even by their own rules we have Cursive so Cljs should be at least yellow there.

roberto18:11:33

and why did they leave out Elm? Elm could be green on all those columns too.

roberto18:11:43

maybe they only wanted Scalajs to have all greens.

mike18:11:52

@malch: what's the link between zelkova and that grid?

roberto18:11:02

anyway, I’ll wave that as just FUD.

mike18:11:14

what's the IDE for elm?

roberto18:11:30

why do you need an IDE? What does that have to do with anything?

roberto18:11:36

tooling is not an IDE

malch18:11:24

@mike: Not the grid specifically, zelkova is an implementation of Elm ideas in cljs

roberto18:11:26

if they had a column that said “IDE”, then okay, I would agree Elm might not fit in that column. But it says “TOOLABLE"

jaen18:11:05

Hm, yeah, that's a point, it's "toolable" so tha ability to build tools around that

mike18:11:18

@malch: I don't know anything about elm, what are these elm ideas?

roberto18:11:27

a big part of Elm is the Elm Architecture. which is implemented in CLJS with zelkova and re-frame.

roberto18:11:36

and in Reactjs with re-dux.

jaen18:11:50

I suppose Elm wouldn't get green on JS interop, because I don't think Elm can manipulate JS objects directly. But then again I don't get why Clojurescript has bad JS interop

jaen18:11:54

In that grid

mike18:11:10

this might not be accurate, I'm just trying to have the big picture, please correct me: om ~ (react + falcor) (reagent + (re-frame or zelkova)) (react + redux) elm

jaen18:11:17

If anything it should be easier than in Scala, since you don't have to type it

roberto18:11:12

I believe you can modify JS objects in Elm via ports

jaen18:11:31

@mike: at least that's how I understand it as well

dnolen18:11:28

@mike more or less though Om is now venturing into innovations over Relay / Falcor

mike18:11:44

@dnolen: but it still has react for the view part?

dnolen18:11:01

@mike for rendering on Web/iOS/Android yes

dnolen18:11:21

but many React idioms don’t really apply since we use React as rendering

dnolen18:11:32

not as application architecture

lvh18:11:49

Hm. I’m trying to write a (greasemonkey-style) userscript with clojurescript. This requires a specific comment block. I used the instructions from here: https://groups.google.com/forum/?fromgroups=#!topic/clojurescript/_qViDrdu30U However, with :advanced the comment block is removed. :whitespace keeps it. Isn’t @preserve supposed to preserve it?

kevinmershon18:11:52

I'm trying to set up a new clojurescript project from a lein template. I'd like to use something akin to Chestnut but more up-to-date, and include om-bootstrap and devcards. I've tried setting this up myself hodge-podging from the Chestnut and devcards templates, and so far it's a big bag of fail. Any suggestions?

halcyon19:11:45

@kevinmershon: unless you need to do some backend stuff, you could just go straight figwheel

kevinmershon19:11:04

@halcyon: I do need to do a backend, yes.

mike19:11:45

who doesn't need backend?

kevinmershon19:11:37

I was reading up on Chestnut's issues on GitHub, and apparently the dependencies are pretty outdated, and the method in which you load up the repl is redundant ever since figwheel incorporated its own repl. I'd rather do without those redundancies, but I like the project structure Chestnut provides

mike19:11:12

is chesnut for om next?

kevinmershon19:11:32

Chestnut is just a template to start off a basic clojurescript project with a backend based in ring

mike19:11:35

why doesn't om come with an official template?

halcyon19:11:42

@mike I suppose I might have meant if you don’t need to write a clojure backend. Although there are plenty of SPAs that don’t require a backend

kevinmershon19:11:50

I need to write a Clojure backend.

mike19:11:41

it introduced itself as: Application template for ClojureScript/Om with live reloading.

dnolen19:11:06

@lvh I don’t know if @preserve is still a thing, I recall that maybe going away?

lvh19:11:48

That would certainly explain it. https://developers.google.com/closure/compiler/docs/js-for-compiler#tag-license still suggests it’s a thing, though.

lvh19:11:53

(@license also doesn’t work)

dnolen19:11:10

@mike just not interested in maintaining templates.

dnolen19:11:24

@lvh I don’t know how up-to-date those pages are

dnolen19:11:32

I just follow along on the mailing list

lvh19:11:32

I’ll try /**!, /*!; the issue tracker suggests the team hasn’t done that yet; but I don’t know how up-to-date the issue tracker is.

lvh19:11:38

Gotcha. Thanks, @dnolen!

bhauman19:11:46

Are folks using 0.5.0-SNAPSHOT without problems? Wanting to push a release.

mike19:11:50

@dnolen: Last updated July 22, 2015.

kevinmershon19:11:15

I guess what I'm looking for is: figwheel (with om), compojure, and devcards all in one lein template

lvh19:11:01

kevinmershon: that’d be nice, but FWIW I’ve stopped wanting that as much after setting it up once or twice. It’s just not that hard simple_smile

lvh19:11:23

Also I am pretty happy about those folks working on making the projects better rather than having to maintain templates 😉

bhauman19:11:32

@kevinmershon: things are still newish and these things require a base of knowledge, an automatic template would just get you standing on the end of a plank

kevinmershon19:11:33

Yeah, I'm clunking around with my project config trying to make it all work together.

lvh19:11:52

bhauman++

lvh19:11:02

setting up figwheel a few times was very instructive

lvh19:11:11

bhauman: I’m working on getting devcards into all the things, FWIW

bhauman19:11:55

@lvh that makes me happy

bhauman19:11:27

It's criminal that I haven't used Om.next and started devcard tooling for it

lvh19:11:42

bhauman: It helps make it easier to demonstrate how to use things; I hope that in the long run this will make us better at helping junior folks.

bhauman19:11:23

@lvh: yeah would love to hear some longer term stories around how its working

lvh19:11:40

I’m working on hiring more junior people so I’ll let you know simple_smile

bhauman19:11:13

man to be a junior dev exploring ClojureScript for my job, such a cool experience, you are going to ruin them for all other dev setups

bhauman19:11:05

Speaking of which I think I'm getting tired of hearing that people should "learn ClojureScript in order to learn some new ideas to bring back to their JavaScript environment". ClojureScript is first class and better programming language period. This is no longer a "what floats your boat" situation.

halcyon19:11:37

@bhauman couldn’t agree more

halcyon19:11:17

I’m gonna go drive a Lotus Elise so I can bring back some new ideas to driving my Ford Fiesta

bhauman19:11:14

gonna use that

wamaral19:11:21

now I want a Lotus Elise and a job that let me write cljs

dnolen19:11:21

going where no ClojureScript has gone before

lvh19:11:37

Oh, wait, I think I might know why this isn’t working. I’m adding the javascript as a :foreign-lib; those aren’t supposed to be affected by advanced compilation at all

lvh19:11:45

so I guess something else is stripping comments...

colin.yates19:11:57

@bhauman: on what venn diagram does figwheel meet Office simple_smile

wamaral19:11:38

I'm sure someone will create a lib using a xls sheet as a datastore

lvh19:11:44

That’s a very big URL 😕

wamaral19:11:24

xls sheet, as in ATM machine

jaen19:11:44

Huh, that's kinda scary. I don't even remember when was the last time I even used Office or something like that.

lvh19:11:18

Is js(-inline)-comment a thing end-users are supposed to use ?

dnolen19:11:55

@lvh: not really

dnolen19:11:13

it’s there for doing type annotations which isn’t really fully supported yet

lvh19:11:15

It doesn’t seem to emit JS comments if I call it from Clojurescript code at least; so I’m guessing I stumbled on some internals.

dnolen19:11:33

so no you should not be using it

lvh19:11:03

dnolen: Are there any other ways to get a comment to show up in the resulting source code besides :foreign-libs + @preserve?

dnolen19:11:27

not beyond :preamble

lvh19:11:57

I didn’t know about :preamble. Thanks!

martinklepsch20:11:36

Good times when people don’t remember good old :preamble simple_smile

stuartsierra20:11:00

Is Object by itself (not js/Object) supposed to be valid syntax in ClojureScript?

dnolen20:11:21

@stuartsierra: hrm it’s just never been the case

dnolen20:11:34

that’s only supported for deftype defrecord reify specify etc.

stuartsierra20:11:40

OK, but it is valid in deftype/defrecord/reify/etc.?

dnolen20:11:51

js/Object might be a problem there, I never tried that myself

thheller20:11:40

shouldn't it be object lower-case?

dnolen20:11:56

it depends

dnolen20:11:04

(extend-type object …)

bhauman20:11:13

Just updated all the deps for the flappy bird code. The code still works flawlessly and appears to be quicker. https://github.com/bhauman/flappy-bird-demo/commit/6a5e301a64db040486aa43369e609aac805d108c

dnolen20:11:15

(deftype Foo [] Object (toString [this] …))

bhauman20:11:32

for an older project that was very cool

dnolen20:11:48

@bhauman: nice though it better still work!

dnolen20:11:05

while tooling woes have been more frequent than I’d like

dnolen20:11:15

old code should work!

bhauman20:11:14

not just cljs: sablono, react, core.async ... all of it works flawlessly and more than likely better

bhauman20:11:28

the magic of transpiling

martinklepsch20:11:41

(defmacro reporting-failing-actions [& body]
     `(let [old-report-fn# ~'clojure.test/report] ; CLJC
        (binding [clojure.test/report #(do (old-report-fn# %) ; CLJC
                                           (report-failing-actions %))]
          [email protected])))
What would be an easy way to make this macro bind clojure.test/report in clojure and cljs.test/report in clojurescript? Do I need two macros?

martinklepsch20:11:21

I thought I could def the report fn with reader conditionals but then I’m not sure how I’d properly unwind that inside the macro.

dnolen20:11:28

@martinklepsch: conditional reading just doesn’t cover macros

asolovyov20:11:11

@bhauman: triggered by your tweet: so far haven't found any problems with 0.5.0, been using it for development every day since thursday. There is only one weird thing with cider and repl-api/cljs-repl, but I'm really unsure what's that, maybe my emacs setup or something... And including piggieback makes cider unable to connect to nrepl, but I'm pretty sure that's not figwheel's problem. simple_smile

dnolen20:11:00

@bhauman: it’s working pretty well for me, it’s my primary mode of working on Om Next along with Node.js REPL + cljs.test

dnolen20:11:16

testing is one of ClojureScript’s killer apps for me now 😛

asolovyov20:11:02

simple_smile I made tests run in browser on every figwheel's reload, and (because we don't have many yet) that's quite nice to get feedback simple_smile

asolovyov20:11:46

@bhauman: also, I've reported before 0.5.0 that .cljc reloading is broken in figwheel for me - that is fixed simple_smile

bhauman20:11:15

@dnolen: really good to hear!

ddellacosta20:11:04

okay, I’m still stumped by something I see other people are dealing with in the context of upgrading to 1.7.170, seeing Exception in thread "main" java.lang.AssertionError: No ns form found in <snip>/src/deps.cljs

ddellacosta20:11:36

this is in a separate project I’m including in my cljsbuild :source-paths. I have upgraded to lein-cljsbuild 1.1.1

ddellacosta20:11:50

when I leave that src path out, the problem disappears (of course)

ddellacosta20:11:04

wondering how to debug this, not even sure why it’s happening

dnolen20:11:48

@ddellacosta: this is because you have a deps.cljs file in your source tree

ddellacosta20:11:09

I see, so that’s a no-no in any case then?

ddellacosta20:11:20

I guess I have to figure out how to make that work correctly

ddellacosta20:11:37

@dnolen, so I guess I should flip the question: how can I include a separate project in the cljsbuild source-paths so I don’t have to constantly delete my built CLJS files, run lein install on that project, etc. during development, if I have a deps.cljs file in the source path (for that project)?

ddellacosta20:11:46

is that not possible now?

dnolen20:11:58

Just makes sure it's on classpath not source path

bhauman20:11:22

@ddellacosta: I have often just added a path to the other project in my source-paths :source-paths ["src" "../my-other-project/src"]

ddellacosta20:11:14

@dnolen, I see—and in that case cljsbuild will pick up the changes? @bhauman yeah, that’s exactly how I’m doing this—the problem I guess is that there is a deps.cljs in that separate project’s source path

ddellacosta20:11:25

didn’t realize that was verboten

bhauman20:11:44

makes sense

dnolen20:11:47

I am amazed it ever worked

ddellacosta20:11:26

if there’s a better way to be able to include separate projects in the source path so that you don’t have to jump through hoops during development, I’d love to hear it

ddellacosta20:11:37

we just tried it randomly one day to see if it works, and it did, so we kept doing it

ddellacosta20:11:52

otherwise the pain of writing code, installing it, cleaning and recompiling from scratch was too much

ddellacosta20:11:10

especially if what you wrote the first time was not working…a nightmare

ddellacosta20:11:08

should that work for lein cljsbuild? I hasn’t for us in my experience, but I’ll try it again and see

exupero20:11:43

It’s worked for me.

ddellacosta20:11:14

@exupero and you don’t have to add the checkout dependencies explicitly to your main project’s cljsbuild config?

exupero20:11:55

No, just the project-level list of dependencies.

ddellacosta21:11:07

okay, let me try that again and see if it works

ddellacosta21:11:04

@dnolen @exupero yeah, so, as I suspected this is just the same thing all over again just with checkouts:

Exception in thread "main" java.lang.AssertionError: No ns form found in <snip>checkouts/<snip>/src/deps.cljs, compiling:(/private/var/folders/yb/qrynr_s51rvd7l9x3fqqtrfr0000gn/T/form-init4629892169254164810.clj:1:125)

ddellacosta21:11:41

this is a real step backward for development in our large project, unfortunately—back ye old clean, re-install separate project, re-build from scratch flow.

dnolen21:11:27

right I don’t know if cljsbuild knows anything about checkouts

ddellacosta21:11:37

if we are not doing this the right way, would love to know—would be happy to tweak this, just not sure what else to do

dnolen21:11:38

I would just move deps.cljs and be done with it

dnolen21:11:42

i.e. put it in standard places

dnolen21:11:48

resources/deps.cljs

dnolen21:11:02

then checkouts should work for you or whatever really

ddellacosta21:11:07

ah, I see—that is the magic bit I didn’t realize. Will happily move to resources/deps.cljs, thanks @dnolen

ddellacosta21:11:42

@dnolen would it be good for me to add that that is the standard location for that here? https://github.com/clojure/clojurescript/wiki/Dependencies

ddellacosta21:11:54

I certainly wasn’t aware, maybe should have been

martinklepsch21:11:34

@dnolen: I’m not sure what that tells me. Can you give me a pointer how to get this working? Tried multiple things but none worked. 😕

dnolen21:11:04

@martinklepsch: write the macro twice or once and require it into the expected places

richiardiandrea21:11:43

@dnolen: should this work?

/**
 * Given a cljs symbol, strip the namespace part.
 */
cljs_browser_repl.views.utils.strip_namespace = (function cljs_browser_repl$views$utils$strip_namespace(sym){
return clojure.string.join.call(null,cljs.core.drop_while.call(null,(function (p1__24688_SHARP_){
return cljs.core.re_find.call(null,/\./,p1__24688_SHARP_);
}),clojure.string.split.call(null,[cljs.core.str(sym)].join(''),/\\//,(2))));
});
cljs code:
(defn strip-namespace
  "Given a cljs symbol, strip the namespace part."
  [sym]
  (string/join (drop-while #(re-find #"\." %) (string/split (str sym) #"\/" 2 ) ) ) )

richiardiandrea21:11:58

gives a SyntaxError: expected expression, got ','

dnolen21:11:17

@richiardiandrea: I have no idea what I’m looking at

dnolen21:11:23

in plain english please simple_smile

richiardiandrea21:11:08

I defined a function with a regex, and when this function is compiled to js, it gives me a SyntaxError: expected expression, got ','

dnolen21:11:00

right still no idea what the problem is

richiardiandrea21:11:04

The regex is #"\." converted to /\./ what am I doing wrong?

dnolen21:11:07

so I don’t know whether it should work or not

richiardiandrea21:11:32

it is a regex literal...

dnolen21:11:42

I always forget the quoting rules and I don’t have time at the moment to load that in

dnolen21:11:52

somebody else will have to chime in

stuartsierra21:11:30

In Clojure (JVM) the \ character is special inside a Regex literal.

richiardiandrea21:11:58

I am escaping the dot (I want to match it exactly)

richiardiandrea21:11:20

I will try in the jvm

stuartsierra21:11:22

So the string "\\." contains one literal backslash and a dot. The regex #"\." should match one literal dot.

stuartsierra21:11:44

I don't know if ClojureScript matches this behavior.

tord21:11:28

@kevinmershon: A more up to date alternative to the Chestnut template? I just use the Reagent template, which is much better. Ripping out the Reagent bits and replacing them with Om takes a minute or so.

richiardiandrea21:11:14

I went here: https://regex101.com/#javascript and the /\./ definitely works in Javascript...

kevinmershon21:11:26

@tord I ended up restarting from figwheel after a convincing conversation with @bhauman and @halcyon

stuartsierra21:11:01

(re-find #"\." "this.is.a.thing") works in ClojureScript (Figwheel REPL) for me.

kevinmershon21:11:06

I'm currently geeking out on how accessible this community is.

dnolen21:11:46

@richiardiandrea: you should also in general qualify your environment or everyone is going to get confused

dnolen21:11:51

I believe this is in a bootstrapped context?

richiardiandrea21:11:13

no no, it is in a cljs app this one

dnolen21:11:31

right that just changes all assumptions

dnolen21:11:45

and very few people are going to be able to give you a straight answer

dnolen21:11:50

myself included

dnolen21:11:28

but yes if it works in ClojureScript JVM but not ClojureScript JS it can be assumed to be a bug

dnolen21:11:43

and then just report it in JIRA and someone will get around to it eventually or you can take it yourself

richiardiandrea21:11:59

works for @stuartsierra in the REPL so I need more investigation 😄

richiardiandrea21:11:17

ok tnx and sorry for the noise

mocker21:11:41

What libraries should I look at to build a client/server where multiple clients will be displaying a page, and then from a ‘control’ page can tell one of the clients to display a different page? Based off searching I’m thinking maybe sente for communication between client and server?

peterschwarz21:11:29

@richiardiandrea: It might not be the #”\.” regex, but the second one: (string/split (str sym) #"\/" 2 ) /\\// is not a valid expression

peterschwarz21:11:54

/\\// being the resulting JS regex

stuartsierra21:11:18

That's it. (re-seq #"\/" "this/is/a/thing") => #object[SyntaxError SyntaxError: Unexpected token ,]

richiardiandrea21:11:50

should work as /\// in javascript right?

peterschwarz21:11:44

Correct me if I’m wrong (no repl at the moment), but in cljs it should just be #”/“and it will be escaped correctly

stuartsierra21:11:56

(re-seq #"/" "this/is/a/thing") => ("/" "/" "/")

richiardiandrea21:11:52

it is converted by the compiler probably

stuartsierra21:11:56

The / is not a special character in Clojure(Script) regex syntax #"", so it should not be escaped.

stuartsierra21:11:03

I don't know why that particular error results.

richiardiandrea21:11:55

because just /// is not a JavaScript regex I assumed I needed to escape

darwin22:11:40

how do I print compilation time warning from my macro?

darwin22:11:00

println outputs it to compiled js output

mocker22:11:29

No thoughts on libraries to pick from? Just trying to figure out where to start. 😛

maria22:11:24

@darwin: There is a function debug-prn in cljs.util. That might help.

dnolen22:11:00

@mocker sente could work yes

dnolen22:11:10

I haven’t used it myself so I can’t say much more about it

darwin22:11:41

@maria: helped, thanks

mocker22:11:07

@dnolen: The use case is basically: Bunch of TVs displaying dash boards, I want to have a page that can control what each TV is looking at.

dnolen22:11:53

@ddellacosta: sorry I missed your last comment earlier. Sure I would add a recommendation. resources isn’t really a standard location it just on the classpath without being in your sources path.

dnolen22:11:12

@ddellacosta: in the wiki I would say “one possible location is …"

ddellacosta22:11:33

no worries. Yeah, that makes sense—will add, and maybe note your point re: why resources vs. elsewhere

mocker22:11:02

Which seems like it shouldn’t be too hard, but not sure about most efficient way to design. Something controlling iframe that has the dashboard maybe?

dnolen22:11:45

@mocker: if you’re using sente don’t see why you need to bother - WebSockets should cover you, you can broadcast to the other clients

dnolen22:11:32

(assuming your dashboards & control panel are all web based clients)

mocker22:11:15

Dashboards are web based, but already exist. So this would be wrapping around to control them.

kevinmershon22:11:37

@mocker Using cljs to change which URL each iframe points to?

mocker22:11:57

@kevinmershon: Kinda what I was thinking.

kevinmershon22:11:41

That'll work so long as you don't need to manipulate the contents of the frame

kevinmershon22:11:41

If you do, I'd suggest building a browser plugin so you can get elevated privileges in the browser

mocker22:11:02

@kevinmershon: No other way to display external page besides iframe though, rigth?

kevinmershon22:11:35

That depends... If it's just html you could load it in and inject it into your cljs app using ajax. But if it has JavaScript and styles you're going to lose all that

mocker22:11:25

@kevinmershon: Ok, you’ve given me some things to think about.

mocker22:11:47

Thanks everyone.

darwin22:11:37

now I would like to know and print macro call-site location, (meta &form) is nil in my case, any ideas?

darwin22:11:13

I want to print compile-time warning including file location:

(defmacro my-fn [& args]
  (binding [*out* *err*]
    (println (pr-str (meta &form)))))

dnolen22:11:12

@darwin you might have to experiment a bit here, not sure why you wouldn’t get line col information

darwin22:11:15

I thought it is because my macro is expanded as a result of another macro expansion, but that is not the case, even top-level macro does not get meta info

darwin22:11:19

investigating...

dnolen23:11:36

@darwin yeah it could easily be a bug

dnolen23:11:57

and perhaps why source mapping gets weird around macros

darwin23:11:12

tried to test it under Clojure 1.7.0 and 1.8.0-RC1 and several clojurescript versions, but without luck

darwin23:11:27

will leave it as a possible future improvement