Fork me on GitHub
#clojure
<
2018-12-26
>
abdullahibra08:12:08

can i do recursive binding ?

abdullahibra08:12:13

(let [x (fn [] (do (something x) "hello"))]) ?

petterik19:12:57

You could either bind the name of the function to x or use letfn.

(let [x (fn x [] (do (something x) "hello"))])
;; or
(letfn [(x [] (do (something x) "hello"))])

abdullahibra08:12:54

(something x) maybe function to save x itself somewhere

abdullahibra08:12:03

my question here, is the internal x equivalent to the outer x ?

kbsant09:12:24

no, the outer x will be re-bound to the expression on the right.

ido14:12:11

hey guys. I am writing a DB lib in Clojure. - I defined a protocol for the API IClient I want to expose. - I also want to give 2 kind of implementations to this protocol. one for a SimpleClient and one for a ShardedClient. - I want the logic to sit in a single place (i.e. not repeated for each concrete implementation) and be dependant on a polymorphic function (get-client [index]), that will return the right client in each case: on the sharded one it will return the right shard, and on the simple one, just return the only client. How can I arrange the logic in an open way?

emccue19:12:28

I feel like more information about what functionality you need in each client might be helpful

victorb19:12:10

starting a bigger, open source project that will most probably be made in Clojure, at least the initial prototype (https://github.com/ipfs-shipyard/cube/) Any handy references/guides on tips & tricks for larger application architecture and possible gotchas? Would be greatly appreciated!

emccue19:12:15

If you want a single polymorphic function you can always use a protocol with a single method or a defmulti

emccue19:12:13

@victorbjelkholm429 That seems interesting, lmk if you need an extra pair of hands. I don't have any particular pointers on large applications because im a bit of an idiot

victorb22:12:34

Thanks for the offer! Start watching the repo on GitHub and you'll get notified when new issues gets opened, then just jump in where you feel like 🙂

emccue19:12:43

I know mount /or component are there for managing stateful stuff

seancorfield19:12:31

Yeah, a +1 for Component to make it easier to swap pieces in and out, as well as managing any system "state" that has a lifecycle (can be started and stopped).

seancorfield19:12:32

Architecturally, try to separate pure business logic from any I/O and/or persistence as much as possible -- makes testing easier and can improve reuse.

seancorfield19:12:31

@victorbjelkholm429 Also, how big do you consider "large(r)"? We have about 86K lines of Clojure at work -- including test code -- and we have it organized in a monorepo with a dozen or so subprojects that can be tested and built independently, as well as being combined into a set of small monoliths. That's helped us develop clear "layers" of reusable functionality around caching, persistence, searching, etc.

seancorfield19:12:33

(and we use clj/`deps.edn` for all of that, with a small shell script to act as a "smart driver" for that)

jaawerth19:12:59

@victorbjelkholm429 I'd suggest checking out https://github.com/juxt/edge - which sort of acts as both example project and scaffolding tool showing the way juxt approaches organizing fullstack clj(s) apps, including some nifty modular sdk-type stuff they use/made. Folks who know way more about it than I do can likely answer any questions about it over in #juxt

jaawerth19:12:47

what I find particularly neat in there is the way they built it all around the clj tool and a combo of scripts in the repo and small libraries

dominicm20:12:41

Thank you 🙂

jaawerth20:12:09

I call 'em like I see 'em 😄

dominicm21:12:41

Are you using edge in production at all? 🙂

jaawerth22:12:26

Not yet - mostly because I don't (yet) do much in the way of clojure at work (I'm still in the phase of restricting it to clearly defined, small services/tools until I get the team working with it), so how much clojure I do depends on time for personal stuff. I've been using it to inform my thoughts on organization and minimalist/modular build tooling though and have edge (or at least a personalized/modified edge) in mind for a couple upcoming projects

jaawerth22:12:41

I'll definitely share my thoughts when that happens though

dominicm22:12:33

That would be wonderful. Right now it is just a distillation of my observations of our client work. More feedback is crucial to making edge great I think 😊

jaawerth22:12:38

sure, though even if it remains mostly based on what you and others in juxt have found to be deal (and why), IMO that's a very useful thing to have from a prolific studio since it's an easy way for someone like me to spot the gotchas I know are coming but not exactly where they'll hit, if that makes sense, particularly with the advent of clj and the "multiple approaches built on minimalist thing" that inevitably comes with something like that

jaawerth22:12:31

which is why I signal-boost edge when relelvant 😉. But yes i do need to spend enough time with it in the context of a real, nontrivial project before I can have cogent feedback

victorb22:12:54

thanks a lot @emccue, @seancorfield and @jesse.wertheim, lots of nice advice! Will dive deeper and ask more specific questions when they arise. Unsure of the large-ness of the whole thing, depends on how the prototype goes. Love the idea of having smaller subprojects in the same repository, will try that out

lspector22:12:22

Has anyone considered/discussed a REBL-based code editor?

seancorfield22:12:16

Given that REBL is closed source, it would require someone rebuilding all of that from scratch and creating a JavaFX-based editor as well which seems like a lot of work and not likely to get much traction, given how the editor space is already... or am I misunderstanding your question?

mseddon12:12:14

I'm currently doing some experimentation getting a vscode WebView REPL with REBL like viewing, although it's very prototype and early days currently. Full code editing would require literally throwing out vscode's editor and using a custom one however, since it's quite strict about what you can do within a vanilla text editor.

mseddon12:12:12

This is definitely a path I feel needs pursuing to it's fullest though, even if it means dropping vscode and building a dedicated electron application.

lspector22:12:35

Ancient Interlisp-D machines had data browsing that REBL is reminding me of, and code editing was integrated with this, and it was lovely.

mseddon12:12:54

I never saw the Interlisp version of that, though I've read many times how friendly it was considered to be. The only experience I have with lispms is mid-90's Symbolics machines, are there any emulators, videos, or perhaps surviving documentation that describe it?

jaawerth22:12:02

@lspector I want to say there were hints of it in the REBL talk from conj but I could be making that up based on having watched https://www.youtube.com/watch?v=c52QhiXsmyI while multitasking 😉

jaawerth22:12:29

at any rate as datafy support increases that seems like a more and more likely possibility

jaawerth22:12:12

it's a neat idea. I have yet to see a super convincing fully structural/graphical editor but as a "mode" you can add to stuff it could be awesome (and just because I haven't seen it doesn't mean it doesn't exist)

👍 4
seancorfield22:12:16

Given that REBL is closed source, it would require someone rebuilding all of that from scratch and creating a JavaFX-based editor as well which seems like a lot of work and not likely to get much traction, given how the editor space is already... or am I misunderstanding your question?

seancorfield22:12:14

I have a workflow (with Atom, but it should be possible with <insert your favorite editor here>) that lets me run REBL and connect my editor to it, so I can use a hotkey in my editor to evaluate code into REBL and have the results displayed in the data browser, and it's easy enough to have both editor and browser visible side-by-side.

4
lspector01:12:40

My question is coming from a place of dissatisfaction with all of the current editor options. Many are near misses (Gorilla REPL and Visual Studio Code + Calva are currently closest IMHO), but none quite nail the sweet spot of ease of setup, ease of use, and implementation of a few key features, specifically bracket matching and auto-re-indentation. Having to use 2 things and make them talk to each other is already out of the sweet spot. REBL seems to be well-enough thought out that it seemed to me that if it supported code editing, with bracket matching and auto-re-indentation, then it might be one-stop shopping for editing and browsing code and data.

seancorfield02:12:02

Ah, right, I remember we've had this discussion before. Yeah, I can't imagine Cognitect adding any sort of editing to REBL -- they're not in the editor-writing business -- so someone would have to write an editor that satisfies your criteria and write a REBL clone as an integrated part of it.

lspector02:12:00

Understood. If anyone who has the skills also sees the beauty of the idea, I'd be an eager tester and user.