-
Notifications
You must be signed in to change notification settings - Fork 309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added named source blocks #831
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, thanks!
Expanding defsrc through sub expressions would be possible since no key could be a sub expression. Furthermore it would allow future expansion (e.g.: fallthrough per source)
I think I would favour this solution.
Syntax-wise, perhaps something this would fit:
(defsrc {:name my-name}
…)
(this is akin to how Clojure functions can be given an attribute set with some metadata information)
Wouldn't something like
make more sense. |
I figured that |
Sry my mobile UI was messed up. |
This parser would run before the button parser, so this should not cause any issues. Instead of the current , try (symbol "defsrc") *> (KDefSrc <$> defsrcP) we would have something like , try (symbol "defsrc") *> (KDefSrc <$> defsrcAttrSetP <*> defsrcP) which would not cause any ambiguities |
True, but It would be best for the attribute set to be optional to allow for backwards compatibility.
Which would previously define the source keys to be the braces, would now be an empty source with an attribute set. |
I was just looking at the code and noticed how
would be ideal. |
Seems more logical to me to simply not parse empty attribute blocks. Either way, I also think that (defsrc :name my-name
a b c) looks fine. |
I implemented the changes. Please take another look. |
I applied your suggested changes. Please take a look again. |
Thank you! |
This PR adds named
defsrc
blocks.To keep backwards compatibility I decided to name them
defsrc'
.There are some design decisions which could be changed:
defsrc'
instead of something else likedefsrc-named
.But I found finding the right name is hard. :|
defsrc'
instead of expandingdefsrc
.Expanding
defsrc
through sub expressionswould be possible since no key could be a sub expression.
Furthermore it would allow future expansion (e.g.: fallthrough per source)
I opted for
defsrc'
as it was the easiest. Also note that keys not defined in this source are passthrough to other layers (_
). This was simply the easiest way to implement.Let me know if you find some issues.