beginners

Getting started with Clojure/ClojureScript? Welcome! Also try: https://ask.clojure.org. Check out resources at https://gist.github.com/yogthos/be323be0361c589570a6da4ccc85f58f.
Jim Newton 2020-09-20T07:23:24.144Z

when defining a namespace, I can use (:require [some-namespace :refer [name1 name2 ...]) Is there a way to only list the names I DONT want to import instead?

Jim Newton 2020-09-20T07:27:53.145100Z

Is it really not allowed to define a function by giving its fully qualified name?

(defn clojure-rte.api-test/-main []
  (clojure.test/run-tests 'clojure-rte.api-test))
I get the following error
2. Unhandled clojure.lang.Compiler$CompilerException
   Error compiling test/clojure_rte/api_test.clj at (31:1)
   {:clojure.error/phase :macro-syntax-check,
    :clojure.error/line 31,
    :clojure.error/column 1,
    :clojure.error/source "/Users/jimka/Repos/clojure-rte/test/clojure_rte/api_test.clj",
    :clojure.error/symbol clojure.core/defn}

             Compiler.java: 6971  clojure.lang.Compiler/checkSpecs
             Compiler.java: 6987  clojure.lang.Compiler/macroexpand1
             Compiler.java: 7074  clojure.lang.Compiler/macroexpand
             Compiler.java: 7160  clojure.lang.Compiler/eval
             Compiler.java: 7131  clojure.lang.Compiler/eval
                  core.clj: 3214  clojure.core/eval
                  core.clj: 3210  clojure.core/eval
    interruptible_eval.clj:   82  nrepl.middleware.interruptible-eval/evaluate/fn/fn
                  AFn.java:  152  clojure.lang.AFn/applyToHelper
                  AFn.java:  144  clojure.lang.AFn/applyTo
                  core.clj:  665  clojure.core/apply
                  core.clj: 1973  clojure.core/with-bindings*
                  core.clj: 1973  clojure.core/with-bindings*
               RestFn.java:  425  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   82  nrepl.middleware.interruptible-eval/evaluate/fn
                  main.clj:  414  clojure.main/repl/read-eval-print/fn
                  main.clj:  414  clojure.main/repl/read-eval-print
                  main.clj:  435  clojure.main/repl/fn
                  main.clj:  435  clojure.main/repl
                  main.clj:  345  clojure.main/repl
               RestFn.java:  137  clojure.lang.RestFn/applyTo
                  core.clj:  665  clojure.core/apply
                  core.clj:  660  clojure.core/apply
                regrow.clj:   20  refactor-nrepl.ns.slam.hound.regrow/wrap-clojure-repl/fn
               RestFn.java: 1523  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   79  nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:   56  nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:  145  nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
                  AFn.java:   22  clojure.lang.AFn/run
               session.clj:  202  nrepl.middleware.session/session-exec/main-loop/fn
               session.clj:  201  nrepl.middleware.session/session-exec/main-loop
                  AFn.java:   22  clojure.lang.AFn/run
               Thread.java:  834  java.lang.Thread/run

1. Caused by clojure.lang.ExceptionInfo
   Call to clojure.core/defn did not conform to spec.
   {:clojure.spec.alpha/problems [{:path [:fn-name],
                                   :pred clojure.core/simple-symbol?,
                                   :val clojure-rte.api-test/-main,
                                   :via [:clojure.core.specs.alpha/defn-args
                                         :clojure.core.specs.alpha/defn-args],
                                   :in [0]}],
    :clojure.spec.alpha/spec #object[clojure.spec.alpha$regex_spec_impl$reify__2509
                                     "0x1f2ac1cd"
                                     "clojure.spec.alpha$regex_spec_impl$reify__2509@1f2ac1cd"],
    :clojure.spec.alpha/value (clojure-rte.api-test/-main
                               []
                               (clojure.test/run-tests
                                (quote clojure-rte.api-test))),
    :clojure.spec.alpha/args (clojure-rte.api-test/-main
                              []
                              (clojure.test/run-tests
                               (quote clojure-rte.api-test)))}
...stuff omitted...

Jim Newton 2020-09-20T07:28:14.145200Z

I guess this is the :exclude option ?

Jim Newton 2020-09-20T07:31:10.145400Z

but apparently I must use :refer :all :exclude [...]

Jim Newton 2020-09-21T07:05:21.159800Z

I wonder what the reasoning for that is. coming from Common Lisp, this seems really bizarre.

Jim Newton 2020-09-21T07:05:56.160Z

perhaps it is to maintain the invariant that the reader remain side-effect free ?

Jim Newton 2020-09-21T07:08:29.160200Z

However, what does the reader do when it encounters

(defn some-ns/fname [] ...)
I.e., the reader parses that and hands it over to spec to verify, then spec calls simple-symbol? on a symbol which is not simple. Did the parser actually create a symbol in the some-ns namespace?

2020-09-21T07:26:57.163300Z

i don't know the answer to that question 🙂

2020-09-21T07:42:06.163500Z

my guess after looking at: * https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L305 * https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L408 * https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L416-L464 is that a symbol (fully-qualified, so with the namespace part) is created, but not in any particular namespace. it appears one can do this kind of thing:

user=> (symbol "hi/there")
hi/there
user=> (find-ns 'hi)
nil
so symbols can be created that are not associated with a namespace. or if that demo was not so good:
user=> (symbol "there")
there
user=> (type (symbol "there"))
clojure.lang.Symbol
user=> there
Syntax error compiling at (REPL:0:0).
Unable to resolve symbol: there in this context

2020-09-21T07:44:53.163900Z

i find many things in clojure to be not so easy to determine reasoning for. sometimes there seem to be answers if an appropriate party is consulted.

2020-09-21T08:24:41.164500Z

I think the intention is to discourage you from creating symbols in another namespace, to keep things modular. If there is a symbol already, you can set it from 'outside' with alter-var-root. Hopefully someone with more knowledge can provide more detail.

amirali 2020-09-20T18:31:39.148600Z

Hi folks. what can cause this? :

Exception in thread "async-dispatch-1" clojure.lang.ArityException: Wrong number of args (3) passed to: clojure.core.async.impl.ioc-macros/put!
besides the fact that I dont have any put! <! >! with 3 arity!

amirali 2020-09-21T11:00:36.167600Z

I checked every async command in the code and no problem than i can find.

amirali 2020-09-21T11:54:55.168300Z

Found out! The guy used <! instead of >! this caused the error

alexmiller 2020-09-21T15:07:03.187700Z

:thumbsup:

phronmophobic 2020-09-20T18:45:00.150200Z

you can use clojure.walk/macroexpand-all to see what code might be producing that problem

🙏 1
amirali 2020-09-20T19:05:44.150500Z

Thank you! but well its a huge project, How should i use it? @smith.adriane

phronmophobic 2020-09-20T19:07:49.150900Z

where did all this code come from?

phronmophobic 2020-09-20T19:08:46.152400Z

i was thinking you would have some narrowed down portion of the code that you could macroexpand, and examine all the put! calls

🙏 1
alexmiller 2020-09-20T19:09:09.153Z

is this clojure or clojurescript?

alexmiller 2020-09-20T19:09:22.153200Z

and which version of core.async?

🙏 1
xceno 2020-09-20T21:06:11.158500Z

Did I get this right about datomic ions: When I deploy a web application, I can still modify the underlying system my main application runs on, because it's just an EC2 instance running linux under the hood? I'm asking because i need libpython-cljto run some python scripts on the backend as well, so I need to have a python environment on wherever my code will run