-
Notifications
You must be signed in to change notification settings - Fork 13
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
duplicate concat as a replacement for append #242
Conversation
Thanks for working on this! :)
That's an interesting idea. Not sure how to implement it yet, but here's a thought: we could start using metadata to annotate deprecated things with a message instructing what to do instead. ; concatenates things
(def concat 42)
^{:deprecated "Use (concat) instead."}
(def append concat)
(meta append)
; => {:doc "concatenates things" :file <fs>/history :line 1 :column 0 :deprecated "Use (concat) instead."} I think adding that metadata as part of this PR is probably a good idea just to start tracking it. We could/should also change To meet your suggestion, we could emit a warning the first time we see a deprecation for a given definition
|
Updated as you suggested, I still need to figure out how to run the CI and check what building the doc looks like then I'll take it out of draft. For the warning I was thinking if instead defining append based on concat it's implementation was (with the limits of my current lisp skills) in the lines of:
Then the cost of checking if the warning is already printed would only be paid by the deprecated function not the new implementation. But as you said it might be stretching it for this PR. |
I was trying to run the pr checks (see also #254) but nothing was happening, does the runner have to be on before I push the commit? Also when I build the docs I still see |
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.
Yep, the runner has to be up and running before pushing at the moment. (TODO) I usually just amend/rebase + push.
Also when I build the docs I still see
append
under stdlib (similar to https://bass-lang.org/stdlib.html#binding-append) am I missing something forconcat
to show up instead?
append
will still show up since it's still defined. concat
should show up too, so I'd expect the only issue is duplication.
It would be great to have the docs mark append
as deprecated. I can put work into that soon (or you can if you're curious).
Woops forgot to reply to this:
If I understand correctly, you mean something like this? (defn append args
(log "(append) is deprecated; use (concat) instead")
(apply concat args)) The advantage of the static metadata approach is we can use it for the docs, which we wouldn't be able to do with regular code that evaluates when the function is called. We can also probably find a way to emit a warning based on that metadata being present, and also avoid spamming the logs multiple times for the same call site. I think at least having it marked deprecated in the docs is a good first step so that's why I prefer having the metadata. |
I have the runner open currently (as of 16:00 CEST) but I don't see the jobs as started above, from looking at other PRs i'd expect they should show something different if they started running. Also I re-ran |
@pfiaux I think builds not running is my fault - it's receiving a https://loop.bass-lang.org/runs/7d2f6c14-14e7-4960-bb11-efaa9c8f4918
Might be better to run |
Pushed a fix, if you want to try pushing again. |
replaces another use of append with concat
7736804
to
8d4504f
Compare
Merging, and I'll start on the docs change now. Thanks again! |
Draft for #114, started with a naive approach, duplicate
(append)
and rename it(concat)
. Then Replaced uses of append with concat and duplicated go test of append for concat.(concat)
based on(append)
with(concat)
So far so good. In terms of deprecation imaging the following points need to be handled:
(append)
can print a warning? does that even make sense? (ideally it would do so once per program execution not per function execution).(append)
be updated to use(concat)
's implementation, or is it better to keep it as a duplicate because it's short.Bare with me I'm still brushing up on my LISP, but feel free to let me know if something is obviously wrong.