This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-07-06
Channels
- # announcements (13)
- # aws (3)
- # beginners (10)
- # calva (3)
- # clj-kondo (1)
- # clojure (63)
- # clojure-spec (15)
- # clojure-sweden (1)
- # clojure-uk (6)
- # community-development (2)
- # cursive (32)
- # datomic (20)
- # duct (1)
- # emacs (11)
- # events (1)
- # fulcro (32)
- # keechma (23)
- # luminus (2)
- # reagent (1)
- # ring (1)
- # shadow-cljs (23)
- # spacemacs (5)
- # specter (4)
- # sql (13)
- # tools-deps (16)
- # vim (1)
- # yada (2)
how much would someone be tarred a feathered if a library they authored introduced a non-namespaced reader tag?
It’s been done a couple times. They were tarred because they actually collided, which is the whole reason to ns
So, don’t do what you know is bad :)
hello, I have to write some java classes because of some API compatiblity, I was looking in some ways to do it, but getting stuck, my last try was just write the class in Java directly, I'm using Cursive, which says it should be fine, but it fails when I try to require my Java class, is it ok to have the java class in the same folder as the clojure sources?
this is my class skeleton:
package com.wsscode.wise.jena;
import org.apache.jena.datatypes.BaseDatatype;
import org.apache.jena.datatypes.RDFDatatype;
public class EdnType extends BaseDatatype {
public static final String TypeURI = "";
public static final RDFDatatype ednLiteralType = new EdnType();
public EdnType() {
super(EdnType.TypeURI);
}
public Object parse(String lexicalForm) {
return null;
}
public String unparse(Object value) {
return "";
}
}
then I try to (:import (com.wsscode.wise.jena EdnType))
, but get Syntax error (ClassNotFoundException) compiling at (core.clj:1:1). com.wsscode.wise.jena.EdnType
clues on what I'm missing here?
so do I have to do it manually? are you aware if cursive can help in some way with that? I never had to deal with Java before, so this is a very confusing area for me
I don't know what cursive has. In general it will depend on what tool you use to manage dependencies or automate builds.
@wilkerlucio Are you using lein
? clj
?
@seancorfield using deps.edn
the java file is in the source path in the correct location I think
Cursive can even detect and auto add the import statement, but for some reason when I try to load in the REPL it says its not there
OK, with lein
you can get it to compile Java code first. With clj
you can use -e
as a JVM option to compile the Java code but that's a bit of a hack.
The bottom line is that Java is Java and should be compiled (and maybe built into artifacts) separately from Clojure.
gotcha, what you suggest as the easiest wya to do it? I tried gen-class first, but was having a similar issue with that, proxy doesn't seem to work because I need the class to be a specific class subtype (but maybe I' m getting this wrong)
is there some way to generate a class that will not require some external compilation process?
I have one project (`deps.edn`-based) and I have a -e
option in various aliases to compile
the code before anything else.
what goes after the -e
?
(pay no attention to the contents of that repo, other than the compile
aspect 🙂 )
That's for pure Clojure with gen-class stuff
trying here, but something is going wrong
I wrote the class gen as:
(ns com.wsscode.wise.jena.EdnType
(:gen-class
:extends org.apache.jena.datatypes.BaseDatatype
:init init
:prefix "edn"
:constructors {[] [String]}
:main false))
(def uri "")
(defn edn-init []
[[uri] (atom {})])
but when I try to compile:
(compile 'com.wsscode.wise.jena.EdnType)
Unexpected error (IOException) macroexpanding clojure.core/gen-class at (EdnType.clj:1:1).
No such file or directory
Unexpected error macroexpanding clojure.core/gen-class at (com/wsscode/wise/jena/EdnType.clj:1:1).
at clojure.lang.Compiler.macroexpand1(Compiler.java:7018)
java.io.IOException: No such file or directory
at java.io.UnixFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(File.java:1012)
at clojure.lang.Compiler.writeClassFile(Compiler.java:7671)
at clojure.core$gen_class.invokeStatic(genclass.clj:638)
at clojure.core$gen_class.doInvoke(genclass.clj:507)
You need to create the classes
folder manually.
(I really wish Clojure would create the classes
folder if it doesn't already exist)
yeah... thanks, it compiled the class now, but still didn't found it, do I need to add classes
to classpath too I guess? (trying now)
got it to run and construct! thanks @seancorfield!
@seancorfield enjoyed the two most recent youtube videos you put up. keep up the good work 🙂
REBL rocks @csd 🙂
The main page of documentation is pretty readable in my opinion:
https://github.com/tolitius/mount
There’s not actually that much to it; it’s pretty easy to get started with, especially because you don’t need to declare an overall system, just create pieces of state as you need them. So mostly you only need defstate
and then start
and stop
.
@seancorfield jdbc next nob question. Imagine I have a propertary driver, how can I interface with it? I can have the driver on my host
@darioszr it's just a dependency -- and then you'll need to tell next.jdbc
the :classname
to use for the driver. Happy to discuss more in #sql
Any advice on a good stratagy of seeding an in memory cache/db/map with data from a db. I've toyed with datascript but was wondering what a good interface to do a direct import of data from one or more db's to a structure that would support the relational aspect as well. I don't have a pressing need to push back to the db from the struture, I'd probably just do that separately and pull back into hte structure if needed.
should I just go row by row manually and make a mongo like map with all the related data as an entry?
that's neat. So just stuff everything in one set entry and create index as my query functions.
I saw the example join, makes sense, it's very low level, so it would just need some abstraction to concepts I'm already familar with
clojure.set has the core relational operators
Yeah, finding some interesting tutorials on the subject
is there something wrong with the following?
(defn cljs-repl
"Starts a ClojureScript REPL over top an nREPL session. Accepts
all options usually accepted by e.g. cljs.repl/repl."
[repl-env & {:as options}]
(if cljs-present?
(do (require 'cider.piggieback.impl)
(cider.piggieback.impl/cljs-repl repl-env options))
(throw (ex-info "Clojurescript not present" {}))))
Its not giving me a file not found exception but a classnotfound exception.
> Syntax error (ClassNotFoundException) compiling at (cider/piggieback.clj:22:9).
>cider.piggieback.implcljs is present on the classpath so I expect i can require a namespace that requires cljs.repl and others and then invoke it
i guess a bare repro is the following:
clj -Sdeps '{:deps {org.clojure/core.match {:mvn/version "0.3.0"}}}'
Clojure 1.9.0
user=> (defn foo [] (do (require '[clojure.core.match]) (clojure.core.match/match [3] [_] :womp)))
CompilerException java.lang.ClassNotFoundException: clojure.core.match, compiling:(NO_SOURCE_PATH:1:50)
user=> (do (require '[clojure.core.match]) (clojure.core.match/match [3] [_] :womp))
:womp
user=>
do i have a mistaken expectation that this should work?that statement worked for me
actually I had to require it first
didn't work in the do statement
the fn rather
why not require it outside
found this The require statement within the function -main is not invoked during compilation. Thus the compiler can't resolve the namespace b and complains.
https://stackoverflow.com/questions/26366251/how-to-require-namespace-inside-function-main
If it's already in the classpath seems like requiring on the outside wouldn't hurt
The problem is that it depends on something that may not be on the class path. This is a bridge to talk to clojurescript and can’t be loaded if cljs isn’t present
the canonical way to handle this is require followed by resolve, in newer clojure versions we have the handy requiring-resolve
which returns a var you can invoke directly