This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-07-02
Channels
- # admin-announcements (11)
- # beginners (183)
- # boot (139)
- # cider (37)
- # clojure (134)
- # clojure-germany (23)
- # clojure-italy (28)
- # clojure-japan (24)
- # clojure-russia (12)
- # clojurebridge (17)
- # clojurescript (222)
- # code-reviews (6)
- # core-async (9)
- # core-matrix (4)
- # datomic (13)
- # editors (2)
- # euroclojure (13)
- # ldnclj (69)
- # off-topic (32)
- # om (3)
- # onyx (24)
- # reagent (10)
- # yada (31)
@dergutemoritz: regarding config as a component, how do you tackle the case that configuration should defined the actual composition of the system?
I just pasted unbalanced brackets into a file while structure mode is on in Cursive, how do I add the extra parenthesis to balance it?
Yeah, I know how to turn it off and on. I was hopping it wasn’t needed.
@pupeno: You can disable SE briefly in the toolbar at the bottom of the screen, or you can cut&paste a closing paren.
Being able to type a close parenthesis when it’s balancing parenthesis out could be a solution.
a cheaper version might be to automatically turn off SE in this case until it’s manually rebalanced (with approrpirate visual indicators)
Yeah, I’ve considered temporarily disabling it, I’ll try to get to the real solution but if I don’t that might be a good workaround.
There are tricky edge cases though, like selecting an unbalanced section of text and deleting it through typing or pasting - I don’t know if I can catch that or not.
@pupeno: Yeah, it would be nice to implement that, but it’s surprisingly tricky to implement correctly. I suspect it would be more confusing than anything.
@cfleming: I created a cursive channel here. I really like your product
Is there a way to wrap the selection in #()? Maybe # when something is selected could do it?
Good idea, there isn’t right now, no. If you select what you want to wrap you can wrap it in parens, but there’s no way to wrap in #() at the moment.
In general the handling of #() could be better - it’s occasionally annoying with Raise, for example.
I’m just getting started with structural editing. I built a cheatsheet and I’m trying to keep it on as much as possible. http://www.cheatography.com/pupeno/cheat-sheets/cursive-on-mac-os-x/
Yeah, I saw that, thanks! One thing that would help with that would be to break it into related sections - perhaps Structural Editing, Structural Movement, REPL, Testing etc
Yes, I’m planning on doing that once the sections become clearer to me.
One other thing I noticed is that you have Execute Current Statement in there - that’s not one you need there probably, it’s only created as an external action so that people can customise the keypress. See https://cursiveclojure.com/archive/662.html for the motivation.
The sections probably mostly follow the menu grouping - see Navigate->Structural Movement, Edit->Structural Editing, Tools->REPL etc
Ok, I’m starting to do it.
What would be the structural editing way of going from (foo (bar (meh))) to (bar (meh))?
Thanks.
Hello, I was wondering if somebody could help me in my understanding of Clojure concerning lists. See, I have two data types (defrecord Maze [cells]) (defrecord Cell [visited? valid-dirs open-dirs]) And I create the maze like so: (defn create-maze [size] "Create a maze sizeXsize large." (Maze. (let [total-cells (* size size)] (map-indexed (fn [idx _] (create-maze-cell idx size)) (range total-cells))))) Now, before that I had a version that handled a maze with dimensions 1x1 as an edge case, something like this: (defn create-maze [size] (Maze. (if (= size 1) (create-cell) (...))))) This returned a Cell. instead of (Cell.) and my test failed (is (= 1 (count (:cells tiny-maze)))) because it then counted the properties inside the Cell., which is understandable. However, even if I then wrote (count (into [] (:cells (create-maze 1)))) the test would still fail and the resulting array looked like [[:visited? false] [:valid-dirs #{}] [:open-dirs #{}]] It unwrapped my Cell and stuck it all into an array, but I just want to stick the Cell as the only item into a list, which I thought (into []) does. So, um, given a Cell object, how do I place it into a list properly?
@dergutemoritz: I can see your point, and thanks for the explanation I don’t really have a use case for making the config a component but it’s interesting to see how other projects are structured
@iae please post code on http://refheap.com mate, it's a bit unreadable in slack
@acron Alright, will do, thanks! https://www.refheap.com/104682
@iae would be useful to see code for create-cell too
@agile_geek: create-cell is there but create-maze-cell is not
@agile_geek: i don't think that's relevant to the issue (but agree would be nice to have a complete sample)
@acron cool I was still reading code in Slack not refheap! Doh!
you're pulling out :cells from maze, but it's counting the Cell map (because that's what :cells is). Just make create-maze always return a list, rather than a single cell or a list
Sorry, I should say, the constructor for Maze should always take a list, rather than a single cell or a list
The full sample: https://www.refheap.com/104683
@acron I'll try your sample out now but yes, it seems I totally forgot something as simple as the list function.
@iae no need to trivialize it, Clojure has a vast number of forms and I forget them all the time
http://clojure.org/cheatsheet is your friend.
I have to re-learn them at every Dojo!
Anyone using compojure-api? I really like it in theory, in practice I’m having trouble organizing my routes and project in a way that seems logical to me based on regular ole compojure sites.
@iae @acron http://conj.io is an even bester friend 😉
@canweriotnow: defroutes*
should allow splitting the routes like in regular compojure
@canweriotnow: Oooh, I'll give it a look and a bookmark, thanks!
@juhoteperi what I’m not seeing is how I would compose routesets from multiple ns’s like I would otherwise, I think the defapi macro is throwing me.
@iae: it is the Clojure Grimoire, use it with care and love.
@canweriotnow: In defapi you can refer to routes created by defroute* in other namespaces
@juhoteperi and compose them something like,
(defapi app
(context* “/foo” []
my-ns/routeset))
Wrong I’m sure, but general idea?
@canweriotnow: That's about right. Though you might need to move the context* to routeset
@juhoteperi: Ahhh, gotcha… I will play and return with questions of a deeper nature. Thank you!
@canweriotnow: I checked and it should work both ways, context* on defapi or defroutes*.
Sweet, thx!
@canweriotnow: ultra helpful, thanks
@acron: np, happy to help 😉
shameless plug though: my talk is already up (from my own audio/video): http://yellerapp.com/posts/2015-06-29-performance-and-lies.html
acron: they're being edited, should start showing up in a few days
@alexmiller: dang, that's fast
When using the Component library, I sometimes find myself introducing bugs in the start/stop handlers, which leaves the system in limbo when trying to do a reset
. I end up having to restart the JVM.
Any folk wisdom on how to deal with that, other than keeping the handlers as small as possible?
@ordnungswidrig: In fact, we just don't do that We disable components via a config setting which they check during the start phase - if that's what you're aiming at.
@annapawlicka: You're welcome! Showing how a "real world" application could be structured was indeed one of our main motivations for presenting Pepa.
@jstaffans My big issue with Component was starting up a Jetty instance and then having some later component throw an exception ... now there's nothing that has a reference to the Jetty instance to shut it down, forcing a REPL restart to recover. I partially addressed this by defining new lifecycle protocols that moved the Jetty initialization later, after the end of (component/start-system).
Yes, this is a problem I've encountered as well.
I find it's only a problem when you're writing new components. After a few iterations to work out the bugs in start/stop, everything works smoothly.
So it doesn't bother me much.
It's theoretically possible to recover from a failed start/stop — the ex-info
thrown from update-system
contains the current state of the system.
But I usually don't bother and just restart Java.
How do you coerce a value into true/value depending on its truthiness?
Like (comp not not)
Thanks.
I vaguely remember a threading macro that would bail out if it hit a nil. Anyone know where it is?
@max some->
(-> 1 ())
expands to (nil 1)
. Is this a bug?
@ordnungswidrig: I get Can’t call nil
, as I would expect
yep, I question the expansion.
why what would you expect... the first of ()
is nil and -> is defined to provide the previous threaded subexpression as the first argument to the next form.
@ordnungswidrig: what expansion do you expect?
user=> (macroexpand `(-> 1 ()))
(nil 1)
user=> (macroexpand `(-> 1 (nil)))
(nil 1)
^^ probably the source of confusion
bostonaholic: like that, yes.
(nil 1)
makes no sense except that’s how the macro is implemented.
(1)
would be as valid. None of both makes sense, thus an error would be the sanest to do, I guess. The actual expression that made me run into this was something like (-> x .getClass())
which is unfortunate.
this is also nice: guess what this evaluates to (-> 1 's))
ok, that might be an edge case.
@ordnungswidrig: what you wanted was (-> x .getClass)
you want to pass to a function, not the invocation of the function
bostonaholic: I now. however the error was confusing.
ah, I agree
welcome to Java 😉
they're getting better for sure
but when you're dealing with macros and the dynamic nature of clojure on a statically typed jvm, it's going to be tough
An easy fix could be that ->
refuses empty lists as forms.
I think the current behavior is prefered IMO b/c passing an empty form is an "exceptional case"
therefor an exception should be thrown
yes, an „EmptyFormException“
Does anyone know of a project that generates like pojo builder classes from a data schema? Use case is to have clojure define the API to java code for itself to consume.