Fork me on GitHub
#clojurescript
<
2015-10-21
>
grounded_sage01:10:20

does anyone know how I can do % keyframes with Garden?

nowprovision04:10:17

ah sorry wrong room

pbaille06:10:56

Hi, what is the clojurescript equivalent of clojure’s extend function?

chedgren08:10:51

there's no extend in cljs

chedgren08:10:47

pbaille: rather, there's no extend, but there's extend-protocol and extend-type

pbaille08:10:12

ok but i need to extend at runtime

chedgren08:10:59

Maybe you could put something together but extend is not implemented in cljs

borkdude08:10:06

there is also specify!

pbaille08:10:47

it is also a macro

pbaille08:10:00

i really need a function

pbaille08:10:05

there’s a proposal for dynamic extend by cemerick a while ago but don’t know if it concretized

emil0r10:10:29

is it possible to define a protocol in one project, have it compiled down to js and then refer to that protocol in another project and extend it there?

thheller10:10:00

@emil0r: no you are going to need the cljs

emil0r10:10:18

is it possible to have the project in your project.clj file and extend it from there and then load the two js files one after another?

emil0r10:10:26

or would the code clash

emil0r10:10:03

ie. project 1 has the protocol. i compile the js file. project 2 has project 1 as a dependancy, extends the protocol in there, compiles to another js file

emil0r10:10:10

website x referes them in order

thheller10:10:14

you are going to need to source .cljs for advanced compilation

thheller10:10:36

well not for advanced compilation but for the cljs compiler to emit the correct code for the procotol

thheller11:10:08

so the source defprotocol is needed, it cannot be reconstructed from .js

mfikes11:10:12

@emil0r: it is possible to use ^:export on protocol methods, FWIW. I've used this to call upon protocol implementations from Objective-C with :advanced. (`TableViewDelegate` in Goby, for example.)

dnolen11:10:52

@richiardiandrea: there are no Namespace objects in ClojureScript. The ClojureScript wiki is pretty good about covering the language differences between Clojure & ClojureScript.

ul13:10:35

Sorry for repeating questions, but I think they get lost because of unlucky timing. I will be grateful for responses. * Why Atom doesn't implement ISwap and IReset, but there are special cases in swap! and reset! functions? For performance reasons? * Do watches prevent atom GCing (I guess not, but want to check)?

dnolen13:10:34

@ul just perf, protocols bring overhead

dnolen13:10:01

and the standard atom is a fundamental state management tool

ul13:10:22

thanks for confirmation!

dnolen13:10:50

nothing in ClojureScript prevents GCing

dnolen13:10:17

(beyond obvious stuff like top levels)

pbaille13:10:42

is there a way to emulate clojure’s extend function in cljs?

dnolen13:10:53

@pbaille: no but there’s less pressure since JavaScript is already fully dynamic

dnolen13:10:12

so you can’t do it syntactically but you can do it effectively.

dnolen13:10:32

if someone wants to submit a patch that implements extend via specify!, that would be welcome

pbaille13:10:11

thank you simple_smile i will try

martinklepsch15:10:11

I have (:refer-clojure :exclude [get set!]) but still get a compile-time exception wrong set! usage. Any ideas?

martinklepsch15:10:40

(I have a custom (defn set! [...] … in the same namespace)

martinklepsch15:10:52

Is exclusion not possible because set! is a special form?

thheller15:10:34

works for me?

thheller15:10:54

hmm but I don't even get a warning if I (defn set! []) without the exclude

thheller15:10:02

ah you get the warning for using set! ...

martinklepsch15:10:03

@thheller: I get the exception on the line set! is invoked, not where it’s defined, have you tested invocation too?

thheller15:10:21

yeah sorry .. I just testing putting it in and not calling it 😛

thheller15:10:12

and yes that probably is due to set! being special

martinklepsch15:10:57

I assume there’s nothing that can be done about this right? (i.e. file under “known limitation”)

thheller15:10:43

probably not without breaking a whole lot of stuff

thheller15:10:21

set! is used by many things (eg. deftype, defrecord)

martinklepsch16:10:15

ok. (def set! set!*) it is then. using set!* in the impl namespace and using set! when used in other namespaces

dnolen16:10:06

@martinklepsch: special forms are actually reserved

dnolen16:10:12

same as Clojure

martinklepsch16:10:21

If they are reserved potentially def’ing them should cause at least a warning?

dnolen16:10:43

not sure what the behavior in Clojure is here

dnolen16:10:51

but happy to take a warning for ClojureScript

martinklepsch16:10:28

cljs.reader/read-string is closer to clojure.edn/read-string than it is to clojure.core/read-string — is that correct?

martinklepsch16:10:43

Would you take a patch updating the docstrings for read & read-string indicating they’re safe in contrast to clojure.core/read-string? Found this pretty confusing and the only answer I could find was in this lenghty SO answer: http://stackoverflow.com/questions/24661655/clojure-clojurescript-clojure-core-read-string-clojure-edn-read-string-and-c

dnolen16:10:40

yes minor ticket for that + patch is fine

richiardiandrea16:10:47

can I see from outside an API that tells me if a symbol is a special function? kind of like Mike's:

(defn repl-special?
  [form]
  (and (seq? form) (repl/repl-special-doc-map (first form))))
But without the need of copy and pasting the map

richiardiandrea16:10:35

I see that in cljs is is-special-fn? (set (keys special-fns))

richiardiandrea16:10:16

but it is in a .cljc...maybe we could refactor and expose repl-special-doc-map somewhere?

dnolen17:10:51

@richiardiandrea: what would be the point of this?

richiardiandrea17:10:07

😄 sorry maybe my knowledge of cljs.repl and cljs.js is not complete

richiardiandrea17:10:46

how can I print doc of a symbol? I saw that in repl.cljc there is a doc macro, but still, in planck Mike copied over the special-doc-map and repl-special-doc-map

richiardiandrea17:10:17

but I am trying to figure out don't worry

richiardiandrea17:10:05

it looks like i cannot pass (doc in-ns) like this to cljs.js/eval-str

dnolen17:10:52

@richiardiandrea: cljs.js is a new thing that very few people actively use & making Clojure like runtime stuff work in it is non-goal

bensu18:10:50

@martinklepsch: on defing reserved words, I have an old ticket that is somewhat related. what if you def a namespace alias? http://dev.clojure.org/jira/browse/CLJS-1271

bensu18:10:56

so issuing warnings on def for a set of reserved words, namespaces and the such could be useful to prevent unexpected behavior for people who misuse def

richiardiandrea18:10:58

@dnolan, can I ask you a question... I see the -evalute protocol fn is called on each evalution...but in case of a browser, just send-for-eval to it

dnolen18:10:35

@richiardiandrea: I do not understand what you are asking

richiardiandrea18:10:46

what happen next? How the browser evaluates?

richiardiandrea18:10:29

sorry for the newbie question 😄

richiardiandrea18:10:33

ah ok I found clojure.browser.repl/evaluate-javascript is it this the evaluation function for a browser?

dnolen18:10:59

I don’t have time to give detailed explanation about how the REPL stuff and cljs.js bits work, sorry

richiardiandrea18:10:46

ok thanks anyways

richiardiandrea18:10:30

when you have time ping me , i would like to help solving CLJS-1473

mfikes20:10:19

[ClojureScript React Native] I took a stab at enumerating a roadmap with potential avenues of pursuit. Feedback welcome: http://cljsrn.org/roadmap.html

darwin21:10:27

cljs-devtools 0.4.0 is out: https://github.com/binaryage/cljs-devtools/releases/tag/v0.4.0, someone posted it on HN a few days ago https://news.ycombinator.com/item?id=10400800, and it got 100+ upvotes, so I decided to do a new release simple_smile

jaen21:10:45

cljs-devtools is the best thing since sliced bread, really

jaen21:10:00

Can't imagine writing cljs without it

martinklepsch21:10:13

I want a boot task that just injects it into my build! (please ☺️)

darwin21:10:12

@martinklepsch: I’m thinking about packaging it as pre-compiled js extern dependency, something you would put into index.html before you include your app entry point, current devtools/install! way of installing it can be too late, the order of requires is not guaranteed and some code might run when requiring other dependencies. Would that work for you?

cfleming21:10:44

@dnolen: How did the training go?

darwin21:10:59

I’m not familiar with boot much...

dnolen21:10:05

@cfleming: went great! Cursive and Figwheel both worked pretty well

cfleming21:10:45

Awesome, great news

dnolen21:10:46

much smoother than when we tried with Light Table (though to be expected for the obvious reasons, IntelliJ is mature commercial product)

cfleming21:10:57

Yeah, no doubt

jaen21:10:58

@darwin: I think it used to not be guarannteed, but I thought there was a fix for that recently

cfleming21:10:23

Once I get a standalone IDE it should be a no-brainer

dnolen21:10:33

@cfleming: yeah we had to save all the IDE settings so that people got REPLs w/o config, that was kind of annoying

dnolen21:10:38

and it didn’t work consistently

jaen21:10:00

At least I remember this being reported here and I think a fix was also done, but that's probably way behind the search fold

darwin21:10:34

@jaen: typically you call devtools/install! somewhere in your main entry file (main.cljs) and there are some dependencies, all top-level code from those deps will run before top-level code in main.cljs. That’s something which is not obvious. And trying to put devtools/install! into first dependency which has no other dependencies didn’t work reliably. Order of deps wasn’t guaranteed as appears in the source file.

darwin21:10:46

I’m glad to hear if that’s fixed.

jaen21:10:26

Unless my memory is playing tricks on me of course

darwin21:10:52

I have a feeling that pre-compiled js file with devtools included before your :main js file would work. I’m just afraid of differences between cljs versions. Imagine someone includes old pre-compiled clsj-devtools with latest app code or vice versa.

martinklepsch21:10:04

@darwin: boot-cljs allows you to inject require’s and init functions to the development shim which is a very useful approach, keeping the complexity of managing development stuff out of your actual application. This won’t fix any inherent loading issues of course. Just thought might be interesting for you simple_smile

darwin21:10:36

@martinklepsch: just reading it, you mean :init-fns here https://github.com/adzerk-oss/boot-cljs#options, right? this will be pretty elegant solution, but as you wrote, it won’t solve guaranteed require order in the main file (if the issue is still there)

darwin21:10:24

I would need some magic, which would tell cljs-compiler to add particular require to all files, that would guarentee my code runs first, then all else

martinklepsch21:10:41

@darwin: yes. :init-fn and :requires are part of build specifications and can be modified by tasks in the build pipeline

dnolen21:10:20

@darwin I think your thing just needs to run after core but before everything else

dnolen21:10:57

we already have that problem for a couple things now

dnolen21:10:30

yeah so this problem already exists for the constants table (under advanced) and the bootstrapped macros

darwin21:10:01

I can imagine it could bring more problems like 'if you have multiple things which need to run first, how do you specify their order'

dnolen21:10:18

well whatever we would do we wouldn’t support that

dnolen21:10:38

but perhaps worth pondering the very restricted useful case

darwin21:10:16

it is not that big problem for cljs-devtools, in the bad case, user does not see formatted values but just plain js output the old-way

thheller21:10:55

FWIW I already do this in shadow-build. Add a require to all files, that file does "runtime-setup" (eg. call (enable-console-print!)) so you don't have to do it in any of your namespaces

darwin21:10:00

it is just annoyance, and puzzling if you don’t exactly understand that your code ran before cljs-devtools install!

thheller21:10:53

obviously does something else for node thus "runtime setup" 😉

thheller21:10:51

would be pretty straightforword to do this for another ns as well

thheller21:10:13

but that doesn't help the general population not using shadow-build 😉

darwin21:10:15

@thheller: thanks for the info, yep there is no drop-in oneliner solution

darwin21:10:30

actually in plastic I solved it by using goog.require directly. My :main namespace contains only dependency to cljs-devtools and a call to devtools/install! and in index.html after including the main :main js file I call something like goog.require("plastic.main”)

thheller21:10:42

that breaks my rule of not changing any HTML when switching between dev/prod 😛

thheller21:10:05

oh wait you do it in the js file, thats fine

darwin21:10:45

but it relies on the fact that cljs compiler compiles all namespaces in :optimizations :none mode, not only those required from :main entry point

thheller21:10:52

hmm I just inject another :main for dev builds, but I think CLJS only allows one :main

darwin21:10:49

wait, good point, if cljs compiler supported ordered list of :main entry points and did goog.require on them in order, that would solve it

thheller22:10:21

yeah ... my recommendation on that point was ignored unfortunately

darwin22:10:59

I volunteer to implement it on compiler side, if there was an agreement and no major obstacles

thheller22:10:13

this issue has a whole lot of discussion about that stuff

darwin22:10:01

looks like a can of worms… 😲

thheller22:10:14

basically nothing I recommended went in ... but I blame only me for not communicating clearly 😞

darwin22:10:00

@thheller: just finished reading the thread, you made really good points there, now I understand a bit more, having collection support for :main would be great, but I can help myself knowing this: In dev mode I might not use :main at all and just goog.require stuff in order I want.

thheller22:10:44

@darwin: most of it was motivated by closure modules, which was the original feature I created shadow-build for which doesn't work without :main but I can see your point of wanting things a bit more flexible