Hey all, is Clojure-dart still actively maintained?
@seancorfield thank you so much
yes
There was a talk at Conj this year (last month): "ClojureDart: still alive, kicking harder - Grand & Dupuch" - so keep an eye out for that video being released (in January, I think).
Also see: #clojuredart
@Iread thanks, why don't I see this channel by default?
There are hundreds of channels here -- we only auto-join new members to about a dozen of them, so folks aren't overwhelmed. New channels are being created all the time. The expectation is that as folks settle in here and figure out their interests, they can join more channels that go deeper on those topics.
You can find all available channels here (desktop app):
Feel free to ask in #slack-help if you need pointers on how to navigate the various Slack incarnations.
There are channels for pretty much all of the Clojure dialects, but we only auto-join new members to #clojure and #clojurescript -- but there are also #jank #babashka #squint #cherry #clojerl #basilisp and probably others I'm forgetting. There are channels for all the various editors and their plugins too, in case you need them @lifeainteasy #emacs #vscode #neovim #cider #calva #conjure #cursive #clojure-repl-intellij etc etc.
I have two slightly weird questions.
Sometimes the first argument of an expression gets special indentation treatment, such as with if:
(if foo
bar
baz)
as opposed to treating all arguments equally, such as with comp:
(comp foo
baz
baz)
Obviously it makes sense, but what is the rule?
Is this considered OK because if is a special form? That doesn't make sense because I could define my own non-special homegrown-if with the same semantics.
Is this considered OK for a defined set of forms? If so, which ones?
Intuitively it feels like this slightly conflicts with the code-as-data philosophy behind structural editing and Lisp in general.
I realize I should probably ask the second question in a separate message, so I'll do just that.To answer one of your questions, if you make a homegrown-if macro and you want it indented as an if it's possible, at least on emacs:
https://docs.cider.mx/cider/config/indentation.html#macro-indentation
Similarly I'm pretty sure you can tell linters like clj-kondo to "treat this macro as this other macro". Not sure about other editors
For cljfmt: https://github.com/weavejester/cljfmt/blob/master/docs/INDENTS.md
No rules. It's just how someone formats their code.
In some projects, it's (if ...) as you quoted it, in others it would be
(if foo
bar
baz)It seems like this has a name, even. The Clojure Style Guide has a section called "Semantic Indentation vs Fixed Indentation". I guess I'm rubber-ducking right now.
FWIW, most folk just live with whatever their editor/Clojure plugin does by default, but the Clojure Style Guide will give you a good sense of how folks expect Clojure code to look.
We use https://github.com/weavejester/cljfmt and really enjoy it - one of the main benefits is not expending effort wondering such things. But yes, the style guide is very helpful for such questions.
What editor are you using @soltanzadehramin?
I'm sure I'm not able to properly steelman the argument for semantic indentation, so my criticism is probably partially valid at best.
It seems like semantic indentation only is relevant when the first argument is "special enough", which seems like something that is difficult to define. Also, none of your own code would be semantically indentable by default, causing conflicting styles in the same code base.
I'm sure I'm missing something here. Is there anywhere I can read more in-depth discussions on this topic?
Maybe what I'm discounting too much is the fact that the first argument is in fact often special in FP (e.g. apply, conj).
I use emacs with CIDER. I don't remember how I set it up now, but I have clojure-mode that does formatting out of the box. I was just curious about the reason behind the choices.
There is a specific difference between "special forms" -- https://clojure.org/reference/special_forms -- and regular function calls.
Ah, it's been years since I last used Emacs so I'm not up-to-date on how the Clojure packages handle formatting...
> The default indentation rules in clojure-mode are derived from the https://guide.clojure.style. Please, refer to the guide for the general Clojure indentation rules.
I remember clojure-mode being a CIDER thing and then emacs releasing their own (essentially hijacking the name). Now I don't know which one I have, haha. But if it's the official emacs one it should be based on Clojure Style Guide.
I have semantic indentation in my emacs right now.
the indentation conventions date back to common lisp, if not further back to the original lisp itself
Trying to figure out the answer to my previous question on my own, I decided to look at the docs for if and I see this:
-------------------------
if
(if test then else?)
Special Form
Evaluates test. If not the singular values nil or false,
evaluates and yields then, otherwise, evaluates and yields else. If
else is not supplied it defaults to nil.
Please see
-------------------------
Here the question mark seems to mean "nillable", but from what I've gathered it's supposed to denote booleans or predicates in clojure. I would have expected it to say the following:
(if test? then else)
What's going on here?The question mark there is like ? in regular expressions, meaning "could be present exactly once, could be omitted".
Is this how the docs are generally written?
Hmm. Makes sense, I suppose. It's showing how the form is used (i.e. text in other people's source code), not the source code for the special form itself.
At least the docstrings and the :arglists metadata in clojure.core, yes.
it's explicitly mentioned on the https://clojure.org/reference/special_forms > Headings for the special forms informally describe the special form grammar using regular expression syntax: ? (optional), * (0 or more), and + (1 or more). Non-terminals are denoted by italics.
That description is only for that page, not for the code in clojure/core.clj.
But yea, the same grammar is used there as well, just in wider contexts. Except for italics, of course.