This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-06-29
Channels
- # announcements (44)
- # architecture (12)
- # babashka (45)
- # beginners (56)
- # calva (16)
- # cider (34)
- # clj-kondo (6)
- # clojure (47)
- # clojure-austin (2)
- # clojure-brasil (3)
- # clojure-europe (39)
- # clojure-germany (2)
- # clojure-nl (1)
- # clojure-norway (39)
- # clojurescript (7)
- # cursive (1)
- # datahike (2)
- # datomic (28)
- # emacs (8)
- # gratitude (3)
- # humbleui (4)
- # hyperfiddle (45)
- # kaocha (1)
- # lsp (94)
- # nbb (2)
- # off-topic (29)
- # practicalli (8)
- # releases (2)
- # shadow-cljs (6)
- # squint (17)
- # tools-deps (12)
- # vim (11)
TIL: you can cider-undef
on a defonce
in order to be able to rerun/redefine it in the current REPL session without needing to restart the whole REPL
I've seen someone bind a keyboard shortcut in Cursive to call a clojure function eg. (reload)
to reload a web server process during local development. Is that something I could do in cider?
Sure. A simple solution would be something like
(define-key cider-mode-map (kbd "<f12>") (lambda () (interactive) (cider-interactive-eval "(reload)")))
thanks @UFAP0C8KU!
@UDE7BJK1N here https://www.youtube.com/watch?v=2nH59edD5Uo&t=2289s I'm demoing a "dev menu" I create for my projects. This is a way of binding a key to show a menu per project with different key actions for that project, like reload, start webserver, clear a chache, calling profilers, etc. You can see the code here https://github.com/jpmonettas/elisp-utils/blob/master/clojure.el
thanks @U45T93RA6 and @U0739PUFQ!
Do folks feel like this is a bug?
user> (list 'var 'foo)
#'foo
Compare to bare Clojure REPL:
user=> (list 'var 'foo)
(var foo)
#'foo desugars to (var foo)
so these are equivalent semantically, the question is what the printer does for a var I think. Clojure's printer re-sugars back to var quote, and I assume something in cider is making a different choice there. it's different, but not sure it's a bug?
(list 'var 'foo)
should never get identified with any foo
vars right? It seems an unequivocal bug if CIDER is identifying the symbol foo
in the form (list 'var 'foo)
with a var of that name, right?
What does (deref foo)
print?
I would guess that cider's #'
formatting tries to accomplish something that Clojure lacks by default. Without an example of that feature it's harder to assess if the bug can be fixed
@U7RJTCH6J it throws because it’s not actually a var.
oops. I meant (list 'deref 'foo)
I’m not sure if it’s a bug either, but I think the behavior of the standard Clojure printer is better because it makes clear that I’m looking at a list and not a var. I ran into this today because my code was throwing trying to call one of these things, and I was looking at it in the REPL and thinking it was a var, because CIDER prints them indistinguishably.
(list 'var 'foo)
at the repl is evaluating that list. var
is a special form that returns a var. the repl is then printing that var. the default printer re-sugars vars to print them as var quotes, #'foo
. But the printer is open and you could print vars as (var foo)
and it means the same thing.@U7RJTCH6J that also throws because it’s not actually a var, it’s just printing like one. it’s a list so it throws class clojure.lang.PersistentList cannot be cast to class java.util.concurrent.Future
there is no actual var foo
here in this example. Just the list ('var 'foo)
. which might evaluate to a var, but it’s not being evaluated, it’s just a list of symbols.
user> (list 'var 'foo)
#'foo
user> (type *1)
clojure.lang.PersistentList
oh right, I am confusing myself here
then yes, I agree it's a bug :)
user> (list 'deref 'foo)
(deref foo)
For both cider and the clojure cli repl.oh, sorry @U7RJTCH6J, I misread, I thought you were asking about (deref (list 'var 'foo))
. Yes, lists with other symbols render normally, only lists of length 2 with 'var
as the first value render in this confusing way AFAICT.
The reason I ask:
> (= '@foo (list `deref 'foo))
true
clojure cli:
user=> (list `deref 'foo)
(clojure.core/deref foo)
cider:
user> (list `deref 'foo)
@foo
and with var:
user> (= '#'foo (list 'var 'foo))
true
user> (= ''foo (list 'quote 'foo))
true
clojure cli:
user=> (list 'quote 'foo)
(quote foo)
cider:
user> (list 'quote 'foo)
'foo
I assume you probably get a similar result for some other sugars like ~
and ~@
.
(-->
id "35"
op "eval"
time-stamp "2023-06-29 16:34:07.272187000"
code "(list 'var 'foo)"
ns "user"
)
(<--
id "35"
value "#'foo"
)
it’s some bug in the printer.
user> (list 'var 'foo)
#'foo
user> (type *1)
clojure.lang.PersistentList
interesting that for deref
it behaves differently depending on whether the symbol is namespaced or not, but not in these other examples
Just checked. deref
behaves similarly to ~
, but cider doesn't re-sugar ~@
.
I think the reason deref
must be namespaced is just based on the how the reader desugars @foo
and ~foo
. Those desugar to the fully qualified functions, deref
and unquote
while var
and quote
are special forms that can't be fully qualified.
Fun fact, afaik (var foo)
always refers to the special form even if you try to make a local binding:
user> (let [var (constantly 42)]
(var 10))
Syntax error (ClassCastException) compiling var class java.lang.Long cannot be cast to class clojure.lang.Symbol (java.lang.Long is in module java.base of loader 'bootstrap'; clojure.lang.Symbol is in unnamed module of loader 'app')