This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-09-02
Channels
- # announcements (3)
- # aws (3)
- # bangalore-clj (1)
- # beginners (88)
- # boot (7)
- # braveandtrue (10)
- # cider (6)
- # cljdoc (8)
- # cljsrn (3)
- # clojure (33)
- # clojure-germany (2)
- # clojure-italy (1)
- # clojure-spec (44)
- # clojure-uk (8)
- # clojurescript (14)
- # datomic (5)
- # emacs (6)
- # events (1)
- # figwheel-main (8)
- # fulcro (9)
- # leiningen (11)
- # lumo (3)
- # off-topic (119)
- # parinfer (2)
- # pedestal (1)
- # re-frame (11)
- # reagent (12)
- # shadow-cljs (162)
- # unrepl (4)
should I ignore http://java.io altogether in favour of nio?
I have a folder (package) full of clj files with the namespace "foo.accounting.aaa" and "foo.accounting.bbb" and etc... The name of the folder (package) is "accounting" and it is inside of a parent folder (package) called "foo". At the top of these aaa.clj and bbb.clj files, I have (ns foo.accounting.aaa and (ns foo.accounting.bbb respectively. In another file, I wish to require both the aaa.clj file and bbb.clj file and alias the contents of both with (:require [foo.accounting :as act] so that I can use functions as act/funcall. Unfortunately, when I attempt this, I get a compiler error: "CompilerException java.io.FileNotFoundException: Could not locate foo/accounting__init.class or foo/accounting.clj on classpath. Please check that namespaces with dashes use underscores in the Clojure file name., compiling:(foo/caller.clj:1:1). Is there a special way to possibly require the parent namespace and alias it so that I can call of the functions under that namespace with the same act/ root? Thank you greatly for help you can offer.
@mcferren Your require
can only reference actual Clojure source namespaces. foo.accounting
isn't, in your code, only foo.accounting.aaa
and foo.accounting.bbb
.
You need to require [foo.accounting.aaa :as aaa] [foo.accounting.bbb :as bbb]
and then you can call functions in aaa.clj
as aaa/fun-call
and functions in bbb.clj
as bbb/fun-call
.
Does that help?
yes - thanks @seancorfield wish it wasn't the case though 😞 namespaces should act like umbrella's
How to check out the source code of the dot .
in Java Interop like (. Math pow 2 4)
?
@stardiviner It’s implemented in the directly in the compiler: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java#L817
if you look at the Parser
inner class you see that it can compile to many different things depending on the arguments
@schmee How do you find and locate this source?
if you look at the top of Compiler.java
you will see that there are a bunch of symbols defined, one of them being DOT
:
static final Symbol DOT = Symbol.intern(".");
If you search for that in the file, you find on line 118:
DOT, new HostExpr.Parser(),
and then you work your way from there 🙂I see, Thanks @schmee
parse-dt always report error:
The Error:
`
Unhandled java.text.ParseException
Unparseable date: "Tuesday, November 22, 2016 10:50:09 AM"
DateFormat.java: 366 java.text.DateFormat/parse
c83b000ba73daad458c36e37f841882825009b3f-init.clj: 15 user/parse-dt
I've tried change the data format EEEEEEEEEEEE, MMMMMMMMMMMM dd, yyyy hh:mm:ss aaa
to some different styles. Maybe the problem is not on the date format. The original is (java.text.SimpleDateFormat. "EEEE, MMMM d, yyyy h:m:s a")
.
I loaded that example in a fresh repl (clojure 1.9, java 1.8) and it worked fine, you may be calling an older version of you parse-dt function for some reason, so maybe try restarting your repl
@hiredman I tried my example in plain lein repl
REPL, works fine, but not work in newly jacked-in cider project REPL or without-project REPL. This is weird.
@hiredman Can you test the library kce-clj
?
`
(defproject kindle-export-notes "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url ""
:license {:name "Eclipse Public License"
:url ""}
:dependencies [[org.clojure/clojure "1.9.0"]
[kce-clj "0.1.0"]
;; [candelabrum "0.1.0"]
])
I got problem on this project.clj definition.
The lein repl
plain REPL is fine, but CIDER jacked-in REPL got error, I don't know how to debug this problem. Anybody can give me some hints on this?
Hello Clojurians, I need some architectural advice. I need some tips for my "Que", people will visit my site, and they will que up and I will have to chunk each "player" into batches. Got any tips on where I can start (reading material)? I never built something like this from scratch. Was thinking about using rabbitMQ.. I will batch them in players/users of 2/10/50/100 depending on what they play.
perhaps a https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/BlockingQueue.html ?
not really sure if that would be sufficient enough for 1k - 300k simultaneous players queing up hmm..
Or well, it's a tool afterall that I can use, thanks
Im gonna look into Langohr and RabbitMq.
hello
Can I overshadow symbols in clojure using macros? E.g. (completely stupid artificial example)
(defmacro add-one [x]
`(let [temp 1]
(+ temp ~x))
This does not work, since temp is "not defined". I know that it should be declared with # at the end, but was wondering if it is possible with clojure to overshadow vars with macrosYes, but you ` will resolve all symbols yielding invalid code here - there are several common techniques to avoid it
Instead of temp
use ~’temp
in both places
temp#
will do the same thing, but will also generate a unique name that won’t conflict with the expanded code
the way it’s working now, I see that I can “Start REPL” which just starts a generic REPL or I can “Start REPL from open project.clj/build.boot” which appears to load my project files
I’d like to be able to do something like type (-main) in my repl and have it run the program
but instead I get error messages like:
CompilerException java.lang.RuntimeException: Unable to resolve symbol: -main in this context
@jm.moreau Don’t type in the REPL, send code to your REPL.
In the file, type (-main)
and press, I think it is CMD+ALT+B
on MacOS to evaluate it.
@jm.moreau are you using ClojureScript?
Cool, even with Clojure, in-ns
doesn't load code in a namespace; you'd need to require it
In your REPL you could
(require 'the-divine-cheese-code.core)
(in-ns 'the-divine-cheese-code.core)
(-main)
(require 'the-divine-cheese-code.core)
(in-ns 'the-divine-cheese-code.core)
(-main)
;;==> CompilerException java.lang.RuntimeException: Unable to resolve symbol: require in this context, compiling:(/Users/moo/Sync/braveandtrue/the-divine-cheese-code/src/the_divine_cheese_code/core.clj:1:5)
(clojure.core/require 'the-divine-cheese-code.core)
FileNotFoundException Could not locate the_divine_cheese_code/core__init.class or the_divine_cheese_code/core.clj on classpath. Please check that namespaces with dashes use underscores in the Clojure file name. clojure.lang.RT.load (RT.java:456)
Yeah, that initial in-ns
(when the namespace was not yet loaded) put things into a degenerate state
@jm.moreau you can also do it with a one-liner: (doto 'my.ns require in-ns)
What is a good conditional restart library in clojure? I am used to using hara.event but i can no longer find the source code.
Looks like there's no way to require all vars in a namespace with clojurescript right? I.e. this works in Clojure but not ClojureScript: (require '[my.utils :refer :all])
require always requires everything in the namespace, the difference is what gets mapped directly to your ns
Yes that's what I mean.. It's not possible to auto-map all the vars into the current namespace with a :refer :all
right?
right, it was intentionally not implemented
idiomatically we use :as
with a clear shorthand instead
the clojure team is very opinionated about maintaining compatibility so :refer :all
and unqualified :use
still work
ok right thanks @noisesmith
oh really? so even in Clojure :refer :all
is discouraged but kept around for backwards compatibility?
that's my experience, yes
if you look at the code for mainstream libraries, :refer :all is very rare
(and at work it's always frowned on outside a test ns where you refer the ns being tested)
It’s not kept around just for backwards compatibility - there is no desire to remove it
There is a preference to name the external functions you’re using
Because people have found that helps in maintenance and understanding
There are some cases where it’s useful when you have code broken into namespaces but still tightly coupled