Fork me on GitHub
#clojure
<
2020-06-25
>
seancorfield00:06:34

@drewverlee I'm very curious as to what costs you feel are associated with a REPL workflow?

seancorfield00:06:05

I have the exact same workflow whether I'm working in a local REPL, a local process that is running a (socket) REPL, or a remote process (again, running a socket REPL). There are no dependencies, and no special code (other than a JVM option to start a socket REPL)

Drew Verlee00:06:27

I suppose I'm referring to the combined nature of several elements. Reloaded workflow, lisp being highly flexable, clojure being hosted. I didn't spend nearly as much time using python, but by comparison, the overall effect was that many options I have in clojure never even occurred to me there. I'm curious if people who have gone deep into other languages/communities feel the experience compares.

phronmophobic00:06:32

I used emacs' inferior python repl with python, but it definitely wasn't idiomatic. I ended up writing things in an odd style compared to others just so I could have a REPL based workflow. there's also some other things about python that don't really make a REPL based workflow easy.

seancorfield00:06:33

I think it's definitely fair to say that the Clojure/Lisp REPL is unlike any other language's REPL.

seancorfield00:06:57

Probably the closest equivalent is the JS console in a browser when running a single page app?

phronmophobic00:06:26

It's definitely the best live ecosystem that I've used a lot

phronmophobic00:06:06

I know people don't consider excel "real" programming, but it's got immutable values, a live environment, and reactive/flow based paradigm

seancorfield00:06:53

True, true. My wife would probably agree with you as she's quite the Excel hound 🙂

metal 3
phronmophobic00:06:41

I'm generally interested in the future of programming and I think there's a lot of room for something more flexible than excel, but with a similar approachability and learning curve

seancorfield00:06:35

I thought Aurora looked very interesting, from Chris... <blank> the guy who created LightTable...

phronmophobic00:06:20

Chris Granger

3
seancorfield00:06:56

old guy's brain forgets names

😁 6
seancorfield00:06:10

I don't use any sort of refresh/reloaded workflow -- don't need it.

seancorfield00:06:32

As for other languages, that's probably a discussion for #other-languages or #off-topic

seancorfield00:06:53

I find my Clojure REPL workflow to be very, very simple and lightweight. A socket REPL on any process. No dependencies. Half a dozen key bindings to simple commands.

seancorfield00:06:31

(OK, so I also use REBL when developing against a local REPL and I do have a bunch of extensions written in ClojureScript for Chlorine, the Clojure/Script package for Atom -- but even if I use rlwrap around telnet I can still interact with any of those processes pretty easily)

Drew Verlee00:06:00

Structured editing alone is a hurtle for many. Again, this isn't a negative thing, it just raises the bar on what you can do. I was showing a friend how I developed and he was more then a little overwhelmed. It just made me wonder if other languages had a similar skill cap. Anyway, I'll take my evening museing to off topic. . Thanks @seancorfield

seancorfield00:06:13

Hmm, structural editing is a spectrum. I think you need paren-matching and paren-aware selection but that's at the "minimum" end. Auto-nesting based on indentation (parinfer) is very helpful -- but some people really don't like. Slurp/barf are useful but also nice-to-have.

andy.fingerhut01:06:03

I am semi-luddite here, I am sure, but highlighted paren-matching and auto-indent via pressing the tab key are all I ever use that are "Lispy", even in Emacs. slurp/barf/etc. I consider nice-to-have, but beyond my inertia level to bother with 🙂

seancorfield02:06:53

Yup. I use wrap-with-( (or [ or {) a lot more than slurp/barf but I do use those occasionally. And I use expand-selection a fair bit (for copy/cut/auto-indent).

seancorfield02:06:42

I'd be very interested to see what editor features Rich and Stu use. I know they both favor a basic setup. I think both use inferior-mode and a plain REPL.

lilactown00:06:21

I think that being really effective in Clojure necessitates investing in certain skills and a certain mental model of programming that is not the status quo in other languages. This can feel like a large up front cost

lilactown00:06:41

However, I have found that that mental model does extend to other languages

lilactown00:06:56

I do get frustrated when the REPL tooling for those languages doesn’t meet my needs tho 😄

seancorfield00:06:29

Having spent 35 years professionally developing software in over a dozen languages, spanning several paradigms, I actually think that Clojure/FP has the simplest mental model and is by far the easiest to work with from an objective p.o.v. -- But extensive exposure to OOP (and especially exclusive exposure to it) makes the FP model harder to learn/internalize. So I think folks with, say, only a Java background will have a much harder time really getting up to speed with Clojure.

☝️ 6
lilactown00:06:55

I’ve been playing around with designing my own code editor focused on Clojure. It’s interesting how a very simple, elegant design can fall out of the idea that programming in Clojure is simply evaluating forms live in the process. Trying to map that to other languages gets difficult, which is a shame

phronmophobic00:06:19

there's a bunch of stuff that I was trying and failing to do in other languages/ecosystems and when I stumbled on to clojure, it was great to 1) have first class support for those workflows 2) get introduced to better versions of the the janky setups I was using

seancorfield00:06:11

Something we take completely for granted in Clojure is that a unit of evaluation is precisely the (..`)` enclosed form that you select -- no more, no less. That is really, really hard to delineate in most other languages, particularly in statement-based languages (which is most languages). I don't think most folks really appreciate how valuable that fundamental concept is...

☝️ 15
sogaiu01:06:51

fine-grained iterative compilation

seancorfield02:06:22

Yeah... and perhaps most importantly, totally under user control, rather than at the whim of the compiler's algorithm 🙂

teodorlu07:06:55

This, precisely, is why I prefer per-file reloading in Python rather than "sending a function definition to a Python process", which the Python package for Emacs supports. Python doesn't delineate the unit of computation as clearly as Clojure

lilactown00:06:09

I guess Jupyter creates a similar workflow to Clojure’s

lilactown00:06:13

for arbitrary languages

David Pham04:06:36

But you fight a constant global environment in Jupyter. How many things can we keep in our head. This is issue in jupyter. They become monsters.

Romit Gandhi06:06:24

Had anyone used Redis with clojure? I'm new to redis so if anyone provides tutorial or any kind of help then it will be very helpful for me.

potetm16:06:38

I would recommend using raw Lettuce or Jedis. No need to use a wrapper. You can follow the Java tutorials directly.

dharrigan06:06:47

yes. I use it quite a bit

Romit Gandhi06:06:04

Do you have tutorial or anything like that for the same?

dharrigan06:06:19

I find the docs on the redis site good. I use this library https://github.com/lerouxrgd/celtuce. There are others 😄

Romit Gandhi06:06:08

Okay, thank you so much.😊

reefersleep07:06:43

I’m dabbling with macros to learn more about them. Does anyone know why I’m getting this error?

(defmacro something
  [& forms]
  `(let [pairs# (->> '~forms
                     (partition 2)
                     (keep (fn [pair#]
                             (when ~(first pair#)
                               (second pair#))))
                     (into []))]
     pairs#))
Syntax error compiling at (/private/var/folders/_d/h17164js38j8rq2hg4bjfxbm0000gn/T/form-init14908207977537678733.clj:6:37).
Unable to resolve symbol: pair# in this context
I think I’ve seen example of using the gensym reader macro to create gensymed symbols in anonymous function parameter vectors before…. And in destructurings, too. So I wonder why it isn’t working here.

delaguardo07:06:09

you are using symbol pair# generated in (fn [pair#] … form in the context of ~(first pair#) where it is unknown

delaguardo07:06:45

simply replace ~(first pair#) with (first pair#)

reefersleep11:06:30

Thanks @U04V4KLKC. I suppose this will give me the first element of the pair unevaluated, though, and I would like to evaluate it, so that I can filter (hence the keep) by truthy vals. How would I achieve that?

reefersleep11:06:14

a pair could be ((and x y) (do-sideeffect)), like in conds

reefersleep11:06:38

(in this case, wrapped in a list to keep them together)

delaguardo11:06:25

coulde you give me an example of input for that macro?

reefersleep11:06:35

(something (and false true) (prn "first") true (prn "second") nil (prn "third"))

reefersleep11:06:46

In this case, I’d like to keep only (prn "second")

reefersleep11:06:40

But since '(and false true) is a truthy val (a collection), I also keep that with the above code.

reefersleep11:06:04

I was experimenting with something like a cond that ensure that exactly one predicate is truthy, which is why I’m trying to find all of the truthy predicates. I want to count them.

reefersleep12:06:55

(defmacro something
  [& forms]
  `(let [pairs# (->> '~forms
                     (partition 2)
                     (keep (fn [pair#]
                             (when (eval (first pair#))
                               (second pair#))))
                     (into []))]
     pairs#))
Seems to do what I want:
(something (and false true) (prn "first") true (prn "second") nil (prn "third"))
=> [(prn "second")]
I’ve no idea whether this is bad form, though.

noisesmith14:06:00

you can do this without eval - the key is to remove the side effecting part at expansion time

(defmacro something
  [& forms]
  `(count (filter identity
                  ~(mapv first (partition 2 forms)))))
you need more complexity if you need to return the rhs of the thing that was truthy though

reefersleep18:06:39

@U051SS2EU cheers 🙂 Let’s say that something is like a cond that evaluates those right hand sides whose left hand sides are truthy - that is, all of the right hand sides, not just the first. What I wanted to do with the code above was to collect all of the right hand sides and then evaluate them sequentially. Being accustomed to fns and not macros, I just went ahead and used gensymed symbols as I would normal symbols, but I understand that it gets more involved in macros. How would you accomplish what I describe?

noisesmith18:06:58

(ins)user=> (something (and 1 false) (println 1) false (pri
ntln 2) true (println 3))
3
nil
(defmacro something
  [& conditions-actions]
  (let [clauses (partition-all 2 conditions-actions)]
    (cons 'do
          (for [[condition action :as clause] clauses]
            (if (= 1 (count clause))
              condition
            `(when ~condition ~action))))))
• edit to handle a trailing single result as cond does

noisesmith18:06:31

maybe I still misunderstand - that will run all actions where condition is true

noisesmith18:06:08

with some elaboration, it could error if two conditions were true, and run none of the clauses or only the first or only the last

noisesmith18:06:12

the hard thing with macros (to me) is to internalize the fact they are just a data transform before compiling, and segregating what needs to be executed while compiling from what needs to be emitted - note how in this example I try to clarify the distinction by embedding pieces of quoted forms inside normal data ops

noisesmith18:06:21

or perhaps doing that makes it worse LOL

reefersleep19:06:41

I think what you are doing seems a sensible way to approach it, to isolate the part that is different from the rest.

reefersleep19:06:29

I think I struggle with exactly what you are describing, separating the code transformation from the emitted code - and also, since I’m just starting out with macros, understanding when to stay on either side of the boundary when using specific functions/macros/reader macros.

noisesmith19:06:22

The rules are quite simple, but just counterintuitive to humans in my experience. Something you quote becomes part of the compiled, something you don't quote instead generates the thing compiled.

noisesmith19:06:53

alternatively, one could say that your macro generates the thing compiled, and the simplest version of that is to quote a list and return it to be compiled

noisesmith19:06:14

simple, but difficult to grasp once you leave the simplest cases

reefersleep19:06:15

Yeah, the simple cases clicked almost immediately, and it felt enticing. And then, once I started mixing syntax quote, unquoting and gensym, boom! Things stopped making sense 🙂

reefersleep19:06:44

I mean, I believe I understand each of those things separately, but not entirely how they mix (and don’t mix) yet.

reefersleep19:06:19

Thanks a lot @U051SS2EU, this helped me greatly! 🍻

reefersleep20:06:01

I like this version, too, but I don’t understand why I don’t have to add # to the end of condition and action. They are, after all, nested inside a syntax-quoted form - but, of course, an unqote-spliced form, too, which I guess negates the outer syntax-quoting when it comes to requiring gensyming symbols?

(defmacro something
  [& conditions-actions]
  (let [clauses (partition-all 2 conditions-actions)]
    `(do ~@(for [[condition action] clauses]
             `(when ~condition ~action)))))

noisesmith20:06:06

the for is not inside `, so needs no gensym

noisesmith20:06:35

the @ plus ` do the same thing as the original cons and ', with more~ different verbosity

reefersleep22:06:49

Yeah, it’s same same. Except that I don’t understand that detail. The for is inside ` from my perspective, just not directly inside.

noisesmith22:06:13

the for uses ` repeatedly, but is not inside it

reefersleep22:06:35

Maybe we’re talking past each other. There’s a (do which surrounds the for`. That looks like “inside” according to normal Clojure code conventions to me.

noisesmith22:06:26

in my version there is no outside the for, and 'do` only quotes that single symbol

reefersleep22:06:17

Yes, and that version I understand (well, actually I’m wondering why the quoted do does not shadow a (defn do that I create in the same namespace, but that’s a different matter)

reefersleep22:06:47

But in my version, I do (heh) have a syntax quote surrounding the for.

reefersleep22:06:05

Yet it does not require the destructuring symbols to be gensymed.

noisesmith22:06:29

do does not exist, it's a compiler feature, if you had a var called do it would not get used in call position (don't make a var called do)

(ins)user=> do
Syntax error compiling at (REPL:0:0).
Unable to resolve symbol: do in this context

noisesmith22:06:55

it is outside the ` again thanks to ~@

reefersleep22:06:08

Another detail learned 🙂

noisesmith22:06:39

(ins)user=> (def do +)
#'user/do
(ins)user=> (do 1 1)
1

noisesmith22:06:59

that's why you should never call anything do

noisesmith22:06:13

but yeah, my code does assume the reader knows do is special

reefersleep22:06:22

Ah, so it was as I suspected - the unquoting negates the quoting. Sounds obvious when I write it out like that… But not when fiddling with gensymed symbols.

noisesmith22:06:06

it's not just negation - it's like each ` pushes to a stack, and each ~ pops, and when you reach empty stack there's no quoting

noisesmith22:06:25

I do not recommend writing code that requires keeping track of that stack :D

reefersleep23:06:25

I guess that’s why I liked your version as well, because it squished the stack manipulation close together for an easy overview, and isolated them to a leaf node, as well.

noisesmith23:06:20

a compromise:

(cons `do (for [... ...] `(...)))

noisesmith23:06:16

or even

(for [... (cons `[do] conditions-actions)] `(...))

noisesmith23:06:36

(that requires my modification which allows either one or two element inputs in the iteration)

reefersleep23:06:34

I liked that one, it was nice.

reefersleep23:06:40

BTW, I avoid shadowing/replacing symbols used in Clojure core functions/macros/special whatevers myself, as well. I really dislike what I see some people do sometimes, like

(:refer-clojure :exclude [+ * and assert or cat def keys merge])

reefersleep23:06:29

(That’s a cheeky stab at clojure.spec.alpha, by the way…)

reefersleep23:06:02

… But I’ve seen other people do stuff like that, as well, and I don’t understand it. I know naming is one of the hard problems of programming, but is it hard enough to justify recycling names? 😄

Casey09:06:56

mornin folks, 👋 I'm searching for a video of a talk. I am pretty sure it was on Youtube and given by Stuart Halloway. I could be wrong on both counts. The video showcased a development style using the repl where everything was def'ed and evaled inline, and IIRC it sort of eschewed separate tests for a pile of (comment)ed code at the bottom of your file. It was very interesting, and I'd like to revisit it, but I can't find it!

cursork09:06:20

Running With Scissors? https://youtu.be/Qx0-pViyIDU There's stuff on 'Rich Comments' and tests at 20 mins in

Casey12:06:02

"Running With Scissors?" is along the same lines, but the video I'm thinking of had a live coding portion (where the presenter was demonstrating live in a repl)

Casey12:06:00

@UHK8B8STX hmm no it wasn't that one, like I said , I remember the video having a live demo of a buffer + repl as the presenter demonstrated their workflow.

simongray09:06:27

Anyone have a quick way of determining that certain values are not adjacent in a coll? E.g. I need to make sure that symbols do not appear right next to each other in a sequence, but they are allowed to appear 1+ spaces apart.

mdiin09:06:43

That should be doable in one pass over the coll. Are you looking for quick as in a nice function in core, or quick as in execution time?

mdiin09:06:16

As for nice function in core, I don't have one off the top of my head, sorry.

simongray09:06:35

just a proper functional way do it that won’t tear my hair out.

simongray09:06:11

Ah, I guess I could reduce and do an early return when the current and last value match the same predicate.

mdiin09:06:28

Something like

(reduce 
  (fn [prev curr]
    (if (a-certain-symbol? prev)
      (if (= prev curr)
        (reduced false)
        curr)
      curr))
  (first coll)
  (rest coll))
maybe?

mdiin09:06:40

Yes, exactly. 😄

cursork09:06:57

(->> "ABBCCCCADTGGH" (partition-by identity) (map first)) ;; => (\A \B \C \A \D \T \G \H)

cursork09:06:03

And I always forget about dedupe

cursork09:06:47

So just (= (dedupe coll) coll) will tell you if there are consecutive dupes

simongray10:06:38

@U093SNDV5 wouldn’t that only work when comparing values by equality, not any pred, e.g. symbol?

simongray10:06:55

(= (dedupe '[a b c]) '[a b c]) if adjacent symbols are not allowed, then this will not register that

simongray10:06:27

Ok, this seems to work and I think it will be close to linear time, right?

(defn- non-adjacent
  "Return `coll` if no adjacent values satisfy `pred`."
  [pred coll]
  (reduce (fn [coll val]
            (if (and (pred val)
                     (pred (peek coll)))
              (reduced nil)
              (conj coll val)))
          (empty coll)
          coll))

(non-adjacent symbol? [1 'a 2 'b]) ;=> [1 a 2 b]
(non-adjacent symbol? [1 'a 'b 2]) ;=> nil

cursork10:06:24

OK. I understood "Anyone have a quick way of determining that certain values are not adjacent in a coll" to mean that no two adjacent values in a sequence can be equal...

borkdude10:06:00

Slightly related: https://github.com/weavejester/medley/issues/47 It's more useful for parsing than validation

simongray10:06:26

@U093SNDV5 yeah, re-reading my original question, it is a bit unclear what I meant. Sorry about that.

simongray10:06:49

@U04V15CAJ so it’s like split-with, but can split into more than two collections? Seems useful.

borkdude11:06:33

@U4P4NREBY The split-when function is lazy btw, so you could short-cirtcuit when you find an error

metal 3
cursork11:06:02

(defn ok? [pred xs]
  (->> xs
       (partition-by pred)
       (some #(and (pred (first %)) (next %)))
       not))
I'm an idiot. The problem is to find any adjacent elements where a pred is true. So partition by the pred. And if any of those sub-sequences match the pred on the first, and contain more than one element then there are adjacent elements. That'll terminate early and partition-by is lazy.

wombawomba11:06:57

how about this?

(defn ok?
  [pred xs]
  (empty? (filter #(apply pred %) (map vector xs (rest xs)))))

simongray11:06:15

@U15RYEQPJ

(ok? symbol? ['a 'b])

Execution error (ArityException) at cuphic.core/ok?$fn (form-init9008355435483086642.clj:3).
Wrong number of args (2) passed to: clojure.core/symbol?

simongray11:06:42

@U093SNDV5 that does seem to work.

wombawomba11:06:40

yeah, it’d have to be (ok? #(and (symbol? %1) (symbol? %2)) ['a 'b])

wombawomba11:06:59

if you only want that sort of thing you can do

(defn ok?
  [pred xs]
  (empty? (filter true? (map #(and (pred %1) (pred %2)) xs (rest xs)))))

noisesmith14:06:58

hmm, what about something like (defn ok? [pred xs] (empty? (keep (partial apply pred) (partition 2 1 xs)))

👍 3
noisesmith15:06:05

oh, with the and construction above...

noisesmith15:06:00

final answer

(defn ok?
  [pred xs]
  (->> xs
       (partition 2 1)
       (keep (fn [[x y]]
               (when (and (pred x)
                          (pred y))
                 ::not-ok)))
       (empty?)))
#'user/ok?
(ins)user=> (ok? even? [1 2 3 4])
true
(ins)user=> (ok? even? [1 2 2 3 4])
false

Stephen Lester16:06:17

I'm sure this gets asked a bunch but search doesn't really work super well for me here: what books were the most impactful for you? I am thinking mostly of functional programming/FP software design/FP software architecture in general, it doesn't have to be Clojure specifically (but ideally yes)

lepistane16:06:38

SICP hands down

mloughlin16:06:51

The Little Schemer (goes with SICP)

👍 6
cursork10:06:53

The Little Schemer is my favourite book on just programming and thinking like a programmer. There’s also more in the series. A Philosophy of Software Design by John Ousterhout is a bit OO-focussed but is excellent (but also controversial - I’ve read a few articles attacking it - that’s maybe what makes it interesting!) Clojure-wise: Joy of Clojure. I received my copy after working professionally in Clojure for a year. But I enjoyed reading it nonetheless (selfish reason being that it confirmed that a few practices I was following independently were probably decent) I’d also recommend Elements of Clojure as a fun and short read. My main reason to recommend these books is that they all offer something a bit different from the standard tomes on programming languages and best practices.

lilactown16:06:45

Elements of Clojure

lilactown16:06:05

Pragmatic Programmer when I was a junior

mloughlin16:06:30

As a side question, has anyone read "ML for the Working Programmer"? It's a Standard ML book that I've got a copy sitting on my shelf un-read. It's supposed to be really valuable (edit: in terms on content...) but it seems to be overlooked for Haskell recommendations

hiredman16:06:48

it is part of the clojure bookshelf

mloughlin16:06:12

There's a clojure bookshelf? 😄

hiredman16:06:43

rich made a list

hiredman16:06:16

I own a copy of ml for the working programmer, and it is freely available online now too

mloughlin16:06:19

Have you read it?

hiredman16:06:03

I have referred to it

hiredman16:06:53

but I also happen to have a side project (for like the last four or five years?) of writing a standard ml compiler, I haven't referred to it for clojure work

3
mloughlin16:06:44

That sounds really interesting!

hiredman16:06:28

it would be if I could pick a parser and stick with it long enough to actually do some compiling

mloughlin16:06:41

What are you writing it in?

mloughlin16:06:47

(If you don't mind me asking 🙂 )

hiredman16:06:23

the end goal is to compile to lua as well

mloughlin16:06:29

Lua gets everywhere, I can see the attraction

seancorfield17:06:59

Maybe a thread for this non-Clojure discussion, or take it to #off-topic ?

👍 12
Dan19:06:33

clojure.java.jdbc/insert-multi! is painfully slow when inserting many rows into a remote postgres database. Tried both inserting as a sequence of maps and sequence of lists of column values. Anybody have any thoughts?

seancorfield19:06:50

@daniel.stephen.lee happy to follow up in #sql to avoid cluttering this channel with DB-specific stuff...

kwladyka22:06:54

(ns api.config
  (:require [server.core :as server]))

(def integrant
  {::server/host (System/getenv "HOST")
   ::server/server {:port (some-> (System/getenv "PORT") (Integer/parseInt))}})
Is a way to refer to ns by keywords, but not really make them as dependency in :require? So I want to refer to ::server/server for configuration, but not really need to use code from this namespace. It can make a potential issues about loop dependency when want to use configuration somewhere.

noisesmith22:06:16

::server/host is just a shorthand for :server.core/host, if you use the expanded form the namespace doesn't need to exist

kwladyka22:06:52

I wanted refer by alias, because during prototyping I change names a lot

kwladyka22:06:17

alternativly I can move (defonce system (atom nil)) to very separate and alone place without deps. It should work.

kwladyka22:06:12

so this is an atom where integrant keep the init

kwladyka22:06:33

yeah, probably make sense then

seancorfield22:06:21

If you want an alias without a source file corresponding to the resolved name:

(alias 'server (create-ns 'server.core))
That works even if server.core doesn't exist as a namespace but you want ::server/host to refer to :server.core/host so you can rename as much as you like.

👍 3
seancorfield22:06:34

Keywords do not have to match an actual namespace.

noisesmith22:06:06

won't having run create-ns interfere with require elsewhere?

kwladyka22:06:34

but probably the right solution is to move system to alone ns

noisesmith22:06:36

(that is, the ns already exists (and is empty and useless) so require becomes a no-op)

lilactown22:06:37

there really, really needs to be a way to alias w/o creating an ns in Clojure(Script)

kwladyka22:06:50

ech I shouldn’t code after midnight 😉

lilactown22:06:53

it’s like the biggest QoL thing I would use every day, working in a system built with Clojure and ClojureScript and using clojure.spec on both ends

seancorfield22:06:34

There's a ticket for it. A very long-standing ticket.

lilactown22:06:49

I wonder if I could write a version for CLJS that “interns” a namespace in the analyzer but that would probably run into the same issue that noisesmith is talking about, where if the ns ends up being real later that a require of the ns would be a no-op

noisesmith22:06:25

that's an intrinsic problem to using create-ns just to make an alias, but isn't any more wrong in cljs than clj - I just wanted to bring it up in this convo since at least for the moment the namespace existed

noisesmith22:06:11

also, if an alias that doesn't point to a real ns is OK, why not :server/host , it's not like we usually have deep structures of nested system components

seancorfield22:06:30

Yup. That's mostly the approach we've taken at work.

kwladyka22:06:42

oh you don’t use namespaced keywrods with integrant?

noisesmith22:06:27

:server/host is namespaced

noisesmith22:06:40

also, integrant is perfectly happy to use eg. [:server :host] - keywords aren't baked in, the dispatch just has to match the extension

kwladyka22:06:18

ok I asked wrong. I mean you don’t use alias for integrants.

kwladyka22:06:03

oh I didn’t try to use something else, than keywords. Interesting.

kwladyka22:06:12

and you keep init result in separate ns to make it readable from all places? So having something like this:

(ns api.system.state)

(defonce state (atom nil))
?

kwladyka22:06:26

to avoid loop dependencies

noisesmith22:06:23

ideally you don't need to access the system from a global binding, if I need it for dev reasons I just use def, and I break dependency loops by using functions that take arguments

kwladyka23:06:21

I don’t want to make everything more complex to pass the HOST variable etc. I wanted keep it simple.

noisesmith23:06:46

IMHO global mutable state is the opposite of simple, but OK

15
kwladyka23:06:27

1 line sounds simple for me to maintenance

seancorfield00:06:03

1 line sounds simple easy for me to maintenance -- fixed that for you

kwladyka08:06:04

How do you avoid using def not starting ig/init when load REPL and overwrite def value when reload ns? If this will be overwritten without halt before, then it wouldn’t work, because port will be blocked. Unless I don’t see obviously solution here it is still simpler for me, than playing with this issues.

kwladyka08:06:47

It can be done alter-var-root but I would say this is simpler

seancorfield16:06:23

If I want to manipulate the system in the REPL, I'll def it in a comment, just for use in the REPL. Reloading that namespace wouldn't overwrite it, because it's not in the code, it's in a comment.

seancorfield16:06:32

For normal use, my -main sets up the system and passes it into the call chain -- so there are no globals.

kwladyka23:06:33

ok I am going sleep, goodnight! 🙂

kwladyka23:06:41

but you are right, maybe def will be enough.

seancorfield00:06:03

1 line sounds simple easy for me to maintenance -- fixed that for you