8000 Refactor doseq to look like clojure's by gavlooth · Pull Request #503 · jank-lang/jank · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@gavlooth
Copy link

This implements doseq
Had to brake it done to smaller functions. But is pretty close to the original.
Semantics are followed

Copy link
Member
@jeaye jeaye left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Apologies for the delay. I have some questions and requests, but I appreciate the help. 🙂

Comment on lines +806 to +810
([ref timeout-ms timeout-val]))
;(if (instance? clojure.lang.IBlockingDeref ref)
; (.deref ^clojure.lang.IBlockingDeref ref timeout-ms timeout-val)
; (deref-future ref timeout-ms timeout-val))
))

Copy link
Member

Choose a reason for hiding this comment

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

Looks like the entire file has been formatted. Please only change the lines related to doseq.

Comment on lines 1404 to 1412
(defn ^:private assert-arguments
[& pairs]
(let [pairs (partition 2 pairs)]
(loop [ps pairs]
(when (seq ps)
(let [[pred msg] (first ps)]
(when (not pred)
(throw (str msg))))
(recur (next ps))))))
Copy link
Member

Choose a reason for hiding this comment

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

I believe this is a duplicate of assert-macro-args, already in this file.

Comment on lines 1460 to 1467
bindings and filtering as provided by \"for\". Does not retain
the head of the sequence. Returns nil."
[seq-exprs & body]
(assert-arguments
(vector? seq-exprs) "doseq requires a vector for its binding"
(even? (count seq-exprs)) "doseq requires an even number of forms in binding vector")
(let [[_ form] (emit-doseq-step nil (seq seq-exprs) body)]
form))
Copy link
Member

Choose a reason for hiding this comment

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

You mentioned this had to be broken up into separate functions. Why is that? If there's an issue preventing us from using the code that Clojure has, we should identify it so it can be fixed.

Copy link
Author

Choose a reason for hiding this comment

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

@jeaye It was broken for clarity, the huge macro was difficult to follow. I don't remember the issue thought

Copy link
Author

Choose a reason for hiding this comment

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

I can rework it, no problem

Copy link
Member

Choose a reason for hiding this comment

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

Ok, cool. Let's keep it as close to Clojure as we possibly can. This will make porting over new changes in Clojure much easier, since they'll be 1:1.

Copy link
Author

Choose a reason for hiding this comment

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

@jeaye doseq updated from clojure core, only tiny adjasments made

Copy link
Member

Choose a reason for hiding this comment

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

Thanks! The PR is showing a huge diff right now, as well as conflicts. It might we easier to spin up a new one or rebase from main, so we can actually just see the doseq changes.

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.

3 participants

0