Skip to content

Conversation

vspinu
Copy link
Contributor

@vspinu vspinu commented Oct 2, 2017

These are extra fixes related to #438.

[cider.nrepl.print-method]))

(def DELAYS (atom nil))
(def DELAYS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not deferred-middleware? Seems like the best possible name to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are not middleware as such, but handlers which are deferred and that. It's also a map of delay objects, thus DELAYS. delayed-handlers is probably a better name.

"Map of `delay`s holding deferred middleware handlers."
(atom nil))

(def LOCK
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really think this should be named differently - LOCK is way too generic (and as it's not a constant I don't think it should all-caps either).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use caps to emphasize that those a global variables. Some form of marking is needed to differentiate them from locals. All-caps is a useful marking technique and restricting it to only constants is a too massive of a restriction IMO.

I can make them dynamic and use *lock* if that's what you are more comfortable with. But we will never use the dynamic nature of the vars then.

As to the names, how about REQUIRE-LOCK?

(delay
(require `~ns)
(resolve-or-fail `~fn-name)))
(locking LOCK
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can't serialize this in some more elegant manner. This combination of delay + locking seems very unclojury to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what is troubling you. Those are rarely used clojure functions, but they do precisely what's needed in that context. Anything else would likely imply more code. Do you have some concrete ideas?

vspinu added 2 commits October 3, 2017 13:42
 - Add docs
 - `run-delayed-handler` --> `run-deferred-handler`
 - `handle` argument --> `trigger-it`
@vspinu vspinu force-pushed the deferred-middleware-extras branch from 7e4ebf6 to 75641b6 Compare October 3, 2017 11:44
@vspinu
Copy link
Contributor Author

vspinu commented Oct 3, 2017

Ok, as per our discussion, I have improved further on docs and naming.

@bbatsov bbatsov merged commit 6804dc0 into clojure-emacs:master Oct 3, 2017
[cider.nrepl.print-method]))

(def DELAYS (atom nil))
(def DELAYED-HANDLERS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ALL_CAPS is unidiomatic Clojure. Any reason we're doing that here?

Copy link
Contributor Author

@vspinu vspinu Oct 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good to differentiate between local and global non-function vars. It enhances readability. Any form of marking down is fine with me, but ALL-CAPS seems nicest. Some use xyz_ for this purpose.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, anything non-private is in effect global, so I'm fine with sticking with the standard notation. Anyways, that's something tiny.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cider-jack-in broken repl with latest from elpa
3 participants