This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-10-05
Channels
- # aleph (190)
- # bangalore-clj (4)
- # beginners (31)
- # boot (127)
- # braid-chat (2)
- # cider (2)
- # cljs-dev (79)
- # cljsrn (7)
- # clojure (81)
- # clojure-dev (1)
- # clojure-greece (40)
- # clojure-italy (3)
- # clojure-korea (8)
- # clojure-new-zealand (5)
- # clojure-russia (5)
- # clojure-spec (87)
- # clojure-uk (13)
- # clojurescript (50)
- # cloverage (10)
- # component (4)
- # core-async (37)
- # cursive (26)
- # datascript (20)
- # datomic (29)
- # editors (2)
- # emacs (12)
- # hoplon (63)
- # jobs (2)
- # lein-figwheel (1)
- # leiningen (17)
- # liberator (2)
- # off-topic (19)
- # om (31)
- # onyx (9)
- # pedestal (4)
- # proton (1)
- # re-frame (22)
- # reagent (13)
- # ring (1)
- # ring-swagger (9)
- # spacemacs (5)
- # specter (4)
- # untangled (24)
- # vim (29)
@dnolen I watched your talk on “Parsing with derivatives” https://www.youtube.com/watch?v=FKiEsJiTMtI&feature=youtu.be
How much of the clojure.spec
implementation is inspired by this (amazing) paper?
@viebel only the parsing bits really and it’s a bit different since clojure.spec
isn’t a typical parsing problem
Does clojure.spec
use least fix point stuff - as in the paper?
Do we support recursive definition in clojure.spec
?
I mean: can we define a spec that references itself in the definition?
YOu know like in Context-Free grammar?
I am trying...
clojure.spec needs to be able to capture the power of context-free grammars in order to satisfy it’s goals
I also wanted to share with you that after your talk, I implemented the regex matcher in clojure and it runs fine in the browser: http://blog.klipse.tech/clojure/2016/10/02/parsing-with-derivatives-regular.html
Let me know if I misunderstood some stuff: this material is really not trivial 😬
the snippet below works in the script/noderepljs
but doesn’t succeed if I put it in self-host-test
(require '[cljs.js :as cljs])
(def st (cljs/empty-state))
(cljs/eval-str st
"(ns cljs.user (:require [foo.core :as foo :refer [bar]]))"
nil
{:eval cljs/js-eval
:load (fn [_ cb] (cb {:lang :clj :source "(ns foo.core) (defn bar [] :bar)"}))}
(fn [{:keys [error value]}] (nil? error)))
can anyone spot if I’m doing something wrong?
should I be binding any variables that are e.g. bound at the REPL but not in the test?
the problem is the :refer
it fails in cljs.analyzer/check-uses
I am trying to spot the problem but I don't see it ....weird
the difference between the version that produces the error and the one that works is:
- when it works, (keys (get <@U07E9BBBN> :cljs.analyzer/namespaces))
has foo.core
- when it doesn’t work, the compiler env doesn’t have that namespace
I think in replumb I have to wrap the require
which leads me to believe the compiler env is not getting bound somewhere?
wrap how?
just a sec
@anmonteiro I am checking here, it's been a while since I touched that https://github.com/Lambda-X/replumb/blob/master/src/cljs/replumb/repl.cljs#L622
(the code was from planck) it does not look like is doing anything fancy
and I have a similar test here that works: https://github.com/Lambda-X/replumb/blob/master/test/cljs/replumb/require_test.cljs#L203
yeah I can’t figure it out
ok let me fire up a replumb repl
@anmonteiro remember one day I was asking about compilation stages...I had to do something like this: https://github.com/Lambda-X/replumb/blob/master/test/cljs/replumb/ast_test.cljs#L11
maybe it is something relevant to you too
but still it does not explain why it works in node
it’s actually using Node too in the Self-host test
so it works here, I see (cljs.user cljs.core foo.core)
in namespaces
(def st (cljs/empty-state))
(def foo-core-load-fn (fn [{:keys [macros]} cb]
(cb {:lang :clj :source "(ns foo.core) (defn bar [] :bar)"})))
(cljs/eval-str st
"(ns cljs.user (:require [foo.core :as foo :refer [bar]]))"
nil
{:load foo-core-load-fn}
(fn [{:keys [error value]}]
(println (keys (get <@U07E9BBBN> :cljs.analyzer/namespaces)))
(println (nil? error))))
Prints:
;; ======================================================================
;; Testing with Node:
(cljs.user cljs.core foo.core)
false
In doo's node testing environmentso it’s failing
oh nevermind, I see foo.core
. what’s false
?
I see foo.core
, false
is (nil? error)
so there’s an error..
yeah true
what’s the error you see?
oh @anmonteiro sorry for the error, I did not set :eval
because I wanted to test with replumb than changed my mind...
so the print is now:
(def st (cljs/empty-state))
(def foo-core-load-fn (fn [_ cb]
(cb {:lang :clj :source "(ns foo.core) (defn bar [] :bar)"})))
(cljs/eval-str st
"(ns cljs.user (:require [foo.core :as foo :refer [bar]]))"
nil
{:eval cljs/js-eval
:load foo-core-load-fn}
(fn [{:keys [error value]}]
(println (keys (get <@U07E9BBBN> :cljs.analyzer/namespaces)))
(println error)))
---
;; Testing with Node:
(cljs.user cljs.core foo.core)
nil
right
so it looks like it's working
using:
[org.clojure/clojure "1.9.0-alpha11"]
[org.clojure/clojurescript "1.9.229" :scope "test"]
yeah I’m using master
something could have broken, would be good to figure out what
@richiardiandrea hrm, I can only repro this when the namespace has already been loaded
when cljs.js/*loaded*
contains the NS
because it skips the load
right
in my tests here I always make sure I reset *loaded*
before the next one
the root cause of my problem is because I already have the NS loaded
I just want to :refer
a few vars
I wonder what Planck does with regards to this
do you know?
not sure, I am checking in replumb
so @anmonteiro the thing is you want to do two (ns cljs.user (:require ...))
where the second one refers more symbols than the first one?
not really, but I suppose they’re equivalent
equivalent because the NS is already loaded, and I want to require it and refer more symbols
I know what the problem is
oh cool 😄
I didn’t load the analysis cache 🙂
oh right
so the NS is loaded, but the compiler doesn’t know about it 😄
yeah I always forget that part
thanks for taking your time to help!
well you did it yourself ah ah 😄