This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-03-14
Channels
- # aleph (2)
- # atlanta-clojurians (5)
- # beginners (38)
- # boot (2)
- # bristol-clojurians (1)
- # cider (31)
- # clara (8)
- # cljs-dev (136)
- # cljsrn (4)
- # clojure (86)
- # clojure-china (1)
- # clojure-greece (1)
- # clojure-italy (24)
- # clojure-nl (1)
- # clojure-spec (21)
- # clojure-uk (19)
- # clojurescript (68)
- # community-development (28)
- # core-async (35)
- # core-logic (4)
- # cursive (1)
- # data-science (1)
- # datascript (1)
- # datomic (46)
- # events (1)
- # figwheel (6)
- # fulcro (11)
- # graphql (3)
- # hoplon (1)
- # jobs (6)
- # jobs-discuss (94)
- # keechma (3)
- # luminus (4)
- # lumo (7)
- # mount (6)
- # off-topic (24)
- # onyx (6)
- # parinfer (31)
- # portkey (3)
- # programming-beginners (16)
- # re-frame (20)
- # reagent (69)
- # remote-jobs (4)
- # ring-swagger (25)
- # schema (1)
- # shadow-cljs (151)
- # spacemacs (2)
- # sql (14)
- # tools-deps (16)
- # uncomplicate (5)
- # unrepl (35)
- # vim (1)
- # yada (72)
So, is &env
supposed to be available in CLJC files in macros that are being expanded for both sides? E.g. if I call a macro without a reader conditional, I’m seeing nil
for &env
(which makes sense to me for clj, but I thought it having :ns
in env was how we detect if we’re in a cljs compilation context).
So, I have been trying to figure out how to accomplish the “function + macro” with the same name in Clojurescript, but also need the function version to exist in CLJ (in the same ns). I thought I could duplicate this macro magic from Om: https://github.com/omcljs/om/blob/master/src/main/om/dom.cljc#L149, but looking at the generated code I don’t think it actually works, and I think it was broken when CLJ support was added (and no one noticed because the function versions work fine, they’re just not inlined by the macro). So, just checking my understanding after beating my head on the wall trying to do something I’d thought I’d seen done in Om: It seems to me that having macros + functions with the same names in the same namespace will never work in a CLJC file. There is no way to prevent the CLJ code from seeing the macro (which circumvents the function in CLJ). I need higher-order function support in both cljs and clj…so, the only way I see to accomplish this is to put the CLJ stuff in an alternate ns, and have users use a condition reader to require the two different nses but alias them to the same alias…e.g.: foo/server_version.clj
(defn f [] ...)
foo/client_version.cljc
(defmacro f [] ...) ; faster inlined version
(defn f [] ...) ; slower, but for HO use
app.cljc
(ns app
(:require #?(:clj [foo.server-version :as foo] :cljs [foo.client-version :as foo])))
(foo/f) ; uses fn in clj, and macro in cljs
(something f) ; uses fn in clj and cljs
That sound right, or am I missing something?shadow-cljs question - how can I get a REPL connection to a running watcher with cider? I have a very minimal project.clj, which should be enough according to the documentation:
:dependencies [[org.clojure/clojure "1.9.0"]
[org.clojure/clojurescript "1.10.145"]
[thheller/shadow-cljs "2.2.8"]]
:profiles {:dev {:dependencies [[cider/cider-nrepl "0.16.0"]]
:repl-options {:init-ns ^:skip-aot user
:nrepl-middleware [shadow.cljs.devtools.server.nrepl/cljs-load-file
shadow.cljs.devtools.server.nrepl/cljs-eval
shadow.cljs.devtools.server.nrepl/cljs-select]}}}
Say I start the shadow-cljs server (in terminal window):
yarn shadow-cljs watch dev
now (in emacs) I start the clj REPL
M+x cider-jack-in
and to get the cljs REPL I try
(use' shadow.cljs.devtools.api)
(shadow.cljs.devtools.api/nrepl-select :dev)
But it's as if the watcher is not found:
Unhandled clojure.lang.ExceptionInfo missing instance
{}
core.clj: 4739 clojure.core/ex-info
runtime.clj: 11 shadow.cljs.devtools.server.runtime/get-instance!
@fbielejec lets take this to #shadow-cljs
@mfikes trying to run Ambly locally (macOS 10.12.6) I'm getting CFSocketSetAddress bind failure: 48
. I am assuming there is some kind of port conflict at work here although if i understand the Ambly source at all it seems to be capable of scanning for an unused port.
ah, you think that was just it grumbling that it couldn't get it's original port choice
i couldn't see any logging in the code around there, maybe the CFSocket stuff is grumbling under the hood
The clj
command is https://clojure.org/guides/getting_started
@mfikes okay, success, it did work... but I'm looking at the Ambly side (https://gist.github.com/mmower/22f5914742b4ea9fcb281bd6e05995b7) and wondering does this look normal to you? It was also pretty slow although maybe that's a one-off cost of firing stuff up?
just to be sure, is the repl i get on the clj
side from that point being handled by Ambly? Or only the what gets executed by the -e
on the comamnd line?
right, i was just making sure that i wasn't accidentally talking to the clojure repl
right, a little non-sequiteur as i was just looking at Goby following the instructions for integrating Ambly
For example, there is a Ambly-based project that allows you to use React Native (named natal
)
my use case is that I am building a Mac Obj-C app which supports scripting of behaviours, I am looking at Ambly to allow me to use ClojureScript instead of JavaScript for the scripting language
so a property of an Obj-C object would be a script text chunk that gets run on certain events
Oh, yes I wanted to be able to use CLJS instead of JS to write the scripts. I have an aversion to plain JS. You don't think Ambly is the right tool?
@sandbags Right. So Ambly can be used during development if you want to produce an app driven by ClojureScript, where all of the ClojureScript is AOT-compiled to JavaScript that is bundled / shipped with the app. If you want an app that can instead compile and run arbitrary ClojureScript, then self-hosted ClojureScript is good. There is actually an older idea (I think suggested by Nolen) to take the guts of Planck and turn it into a native library that is embeddable into native apps that want this capability.
Something similar could probably also be done with Lumo (which would result in a V8 engine instead of JavaScriptCore)
FWIW, you can also just use self-hosted ClojureScript in a native app. Replete is an example of this. (It is an iOS app that can run arbitrary self-hosted ClojureScript code.)
anyone know of a library that will take a map or a list of maps and lowercase dash the keys? so my api does stuff like { EditListItem: 1, UserName: 'me'} and I'd like it in {:edit-list-item: 1, user-name: "me"} keywordize for clojurescript just does a strait :
addition
just do a map replacing lowercase with lowercase, replacing uppercase with - before uppercase, and remove the first - or skip the first capital
there is also https://github.com/google/closure-library/blob/master/closure/goog/string/string.js#L1421-L1430 right in the closure lib
That’s a great little piece of code golf. I had to stare at it for a minute or so to figure out how that could possibly work.
I got the impression that the EDN reader had been superseded by the reader, so I included org.clojure/tools.reader as a dependency, and disabled the js reader. This creates a 900K file after advanced compilation. I didn’t look at transit because the format of EDN is easily human-readable and human-writable. My EDN is coming from DNS TXT records. Two questions. Is there an EDN-only reader that produces more compact code? Should I just use transit?
@pbw it is unlikely that tools.reader is the cause of this size. it is fine to use tools.reader otherwise. transit is a bit faster but that might not matter.
:dependencies [[binaryage/devtools “0.9.9”] [cljs-ajax “0.7.3"] [org.clojure/tools.reader “1.2.1”] [prismatic/dommy “1.1.0"]]
Of course! Pardon my ignorance, but how can I specify a dependency under :buildname :target :dev?
its not the dependency, its your require for it. you should only be using the devtools.preload
via :preloads
I think