Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Arne Brasseur
@plexus
does ::set/foo make sense? if setprefix refers to a namespace then it should be :set/foo right? double colon is a shortcut to create keyword in current ns, or?
I may be missing some context here, but you can use ::foo/bar when foo is a namespace alias, e.g. (require '[hello-world :as foo]), then ::foo/bar is the same as :hello-world/bar
thanks for all the quick merges!
Lars Andersen
@expez
@plexus Does cljs support it, though?
Lars Andersen
@expez
Let me try with the updated reader
Invalid token: ::set/foo
bleh
Arne Brasseur
@plexus
oh really? that's surprising... but good to know
Lars Andersen
@expez
I'm not sure why it happens, makes no sense to me
I'm inclined to believe I'm doing something wrong
Arne Brasseur
@plexus
always a good belief to start from :)
Benedek Fazekas
@benedekfazekas
thx for the insight @plexus. strange... so is that a case of cljs being a bit behind in implementation or is this an undocumented feature of clj? (talking about the ::foo/bar style keywords)
Benedek Fazekas
@benedekfazekas
or am i completely confused? ;)
Lars Andersen
@expez
definitely a feature
If you google 'keyword alias clojure' you'll get some examples
I've been using this in clojure, in conjuction with spec, yet I got tripped up when you asked if they were legit a little while back
They aren't very intuitive
Benedek Fazekas
@benedekfazekas
is that documented somewhere? i only remember to see :foo/bar style in clojure doc
i seldom use them tbh. not much spec or datomic lately
Lars Andersen
@expez
clojure-emacs/cider-nrepl#224 here support was added to cider
there's no docs for this in the reader docs for clojure
You can even destructure using auto-resolved keywords, which will again be bound to only the name part of the key:
(require '[person :as p])

(let [person {::p/name "Franklin", ::p/age 25}
      {:keys [::p/name ::p/age]} person]
  (println name "is" age))

;= Franklin is 25
seems they are called 'auto-resolved keywords'
Benedek Fazekas
@benedekfazekas
bit confusing tbh... thx for the info @expez
Benedek Fazekas
@benedekfazekas
ok so you need use :: to use the defined alias from the require. with :person/ you are using the full ns name unaliased
Benedek Fazekas
@benedekfazekas
may be missing something here but reader works OK for me if the ns defining the namespaced keyword is properly loaded
user> ::some-test/foobar
;; contemplate => :insight-testbed.some-test/foobar
user> (reader/read-string "::some-test/foobar")
;; contemplate => :insight-testbed.some-test/foobar
user>
using [org.clojure/tools.reader "1.0.0-beta4"]
Lars Andersen
@expez
@benedekfazekas It works fine in clojure, the problem I'm having is in cljc files
Try adding this to the end of cljcns.cljc in test-resources and running the test:
#?(:cljs ::set/foo
   :clj ::inst/foo)
Even though both set and inst are valid aliases the reader fails
I'm guessing we have to provide the reader with the cljs aliases too. It seems weird though, as it's only going to skip that form
Arne Brasseur
@plexus
would it be interesting to add support for marking :require forms with metadata as being purely for side-effects, i.e. should not be cleaned up by clean-ns?
e.g.
(ns foo.bar
  (:require [clojure.set]
            ^:keep foo.with-side-effects))
I know there's support now for configuring patterns of namespace names to be left alone, but IMO having it like this in the namespace is sometimes preferrable, and it serves as documentation to other devs
Lars Andersen
@expez
@plexus Yeah, having both would be nice. Especially for namespaces like user.clj where you often require things without using them all the time
Arne Brasseur
@plexus
Alright, took some digging into how the namespace is read and written out again, but I've managed to get it working and submitted a PR
Lars Andersen
@expez
Awesome @plexus!
So sorry you had to touch the pprint code. It's an atrocious mess :(
Arne Brasseur
@plexus
that wasn't too bad :) figuring out how the ns form was getting read and transformed was a bit more tricky, but the CIDER debugger was a great help
Lars Andersen
@expez
yeah the debugger is a boon :)
Benedek Fazekas
@benedekfazekas
@expez, @magnars fyi i plan to cut a long overdue cljr release soonish (in april lets say). afaik #175 was a blocker but it is not anymore. also want to solve #169 most likely by forking alembic to be able to upgrade its dynapath dependency. that is the only thing in my list pre release. also i am off the grid more ore less until 25th april so this is an early and hopefully fair warning... ;)
Lars Andersen
@expez
Sure @benedekfazekas, we've been talking about cutting a release forever, but there always seems to pop up new stuff to fix first :p
I agree that it's long overdue, though
Julien Fantin
@julienfantin
Hi folks!
Was looking into #195 yesterday for a little bit and had a couple questions
First of all, is mranderson a requirement for dev? I gave up on it after 20min, lein cleaned and just jacked into the project and everything seemed to work but I'm wondering if I could get into weird situations doing that?
Secondly, something came up with the cljs analyzer pretty quickly: most nodes src positions only contain line and column, it seems only a few have end line and end column, so all the node-at-loc? logic kinda falls apart