This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-03-07
Channels
- # beginners (49)
- # boot (48)
- # cider (5)
- # cljs-dev (6)
- # clojure (165)
- # clojure-android (1)
- # clojure-austin (1)
- # clojure-india (2)
- # clojure-italy (23)
- # clojure-nl (2)
- # clojure-poland (4)
- # clojure-russia (63)
- # clojure-spec (5)
- # clojure-uk (121)
- # clojurescript (187)
- # core-async (1)
- # core-logic (4)
- # cursive (17)
- # datascript (1)
- # datomic (12)
- # emacs (2)
- # funcool (3)
- # hoplon (2)
- # jobs (7)
- # juxt (6)
- # lambdaisland (1)
- # luminus (2)
- # lumo (20)
- # midje (8)
- # off-topic (11)
- # om (38)
- # onyx (42)
- # pedestal (6)
- # planck (23)
- # protorepl (29)
- # ring (3)
- # rum (23)
- # spacemacs (6)
- # untangled (70)
- # vim (1)
@seancorfield The cljs compiler (boot_cljs) is somehow not able to locate that namespace. Is it part of some package one must require in build.boot (this is for a CLJS project)?
@seancorfield Thanks, good to know!
I’m trying to require a macro from sablano into a cljc file. It loads in CLJS but not in CLJ
In the namespace foo-bar.core
I've got (defrecord Baz [left right])
.
In another namespace foo-bar.core-test
I want to check for membership using (instance? Baz a)
.
I've added the import to the ns macro (ns foo-bar.core-test (:import [foo_bar.core Baz]))
,
But the check with instance?
fails because a
is a foo_bar.core.Baz
, not a Baz
.
Is there a way to import a record type so I don't have to specify the fully qualified name?
@vinai huh, that is suprising... Baz
should map to foo_bar.core.Baz
when imported as you have. how is a
defined?
i have a list of files stored in an atom like this:
user> (take 5 @g)
(#object[java.io.File 0x593890b8 "dest/file0"] #object[java.io.File 0x33e303d8 "dest/file1"] #object[java.io.File 0x2fb5d0a2 "dest/file10"] #object[java.io.File 0x5ea35c6d "dest/file100"] #object[java.io.File 0x4303ba51 "dest/file1000”])
and i want to delete some files, but it looks like delete-file
accepts a string, not a file object. I see that this works:
user> (delete-file (str (.getParent (first @g)) "/" (.getName (first @g))))
true
I can tolerate this, but i get the feeling that there’s a better way than re-deriving the file path and file name. it’d be great if there was a delete-file
for file objects.Why not just call .delete
on the File
object?
(.delete (first @g))
@mruzekw: :refer-macros
is a CLJS-only construct. From CLJ you'd just use :refer [html]
. For CLJC, you might want a reader conditional as @carly suggested
Thanks @timgilbert
It might be simpler to just do :require [sablono.core :as s] ... (s/html [:head ...])
, with more recent versions of ClojureScript the CLJS compiler will figure out what things are macros and pull them in on :require
Getting macros working in CLJS still seems like a bit of a black art though. You might find this useful if you're mixing macros and CLJC: https://github.com/cgrand/macrovich
i found:
(map #(.delete %) (take 5 @g))
deletes the first five files in @g
. thanks @seancorfield !@mfm See also memfn
I am trying to understand how class loading works.. I am using clojure.string in one of my functions and somehow the code throws runtime error 'java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils’ SO looks like ‘org/apache/commons/lang/StringUtils’ class is not found.. What is the right way to fix this?
That’s… weird. clojure.string
has no direct dependency on anything other than java and clojure itself
Perhaps you could paste the code in question?
Do you have something like (ns foo (:require [clojure.string :as string]))
at the top of your file @payal? Maybe somehow your editor tried to automatically import a different string library or something?
Very odd, I'm not sure
No, the stuff I posted above should be correct
But I was thinking sometimes IDEs can auto-insert other classes for you and it's easy to get the wrong one sometimes
But you'd see it in your code
If you're using leiningen you could try running lein deps
from your project to make sure your local repository has the correct dependencies
hmm okay let me do that .. by that you mean there should be no package other than clojure.string which lein is puling right?
How are you running your code?
Basically if you have a leiningen project, all the classes that are loaded when you run your code should come from the :dependencies
key in your project.clj
You can run lein deps :tree
to view the whole tree of jar files that lein will pull in based on that list
And lein deps
by itself will try to download any files that you don't have locally
thanks I was looking for this command because lein deps does not shoe downloaded packages
If nothing else you can start from scratch by deleting ~/.m2/repository
and then lein deps
again. Not sure about the exception you're getting
But yeah, just with the code you posted I wouldn't expect it to require the apache string libraries
yeah i am also not convinced that it would require StringUtils, but then it is failing with that exception so not sure…thanks for the help though 🙂
is there a way to find out what protocols something implements?
like given an object get back a set of protocols
did you go through this https://clojure.github.io/clojure/clojure.reflect-api.html?