feat: @entered — ask which marked definitions one call went through - #24
Merged
Conversation
Contributor
|
📚 Docs preview: https://codes.sota-shimozono.com/ExperimentalAPI.jl/previews/PR24/ (updates on each push to this PR) |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
entered()answers this about a whole process.record(() -> f(x))answers it about one call, andis what this is built on. The macro earns its place by knowing two things a closure cannot: the
source text of the expression, and the line it was written on.
It returns the value of the expression, so it drops into existing code the way
@timedoes.The last line is the point
"Entered nothing" and "nothing is marked anywhere" are different states, and a package that has
not adopted this yet is in the second one. A report that could not tell them apart would read as
reassurance on a package where nothing had ever been declared. The two branches print different
text, and the tests assert both — a report that always printed one of them could not pass both.
What the tests pin that nothing else would
exprinto both the run andthe report doubles every count it prints, and the count is the answer. Verified by mutation:
splicing a second time makes the test read
2 == 1.@__LINE__taken on the same line, so areport naming the macro's own definition site would fail.
Two deliberate omissions, both stated in the docstring
this asks the question that needs neither.
and Base's higher-order functions are in it —
sum(f, xs)over a generator reportsdriver → sum → mapreduce → mapfoldl → mapfoldl_impl → foldl_impl → _foldl_impl → MappingRF → inner → energy, three names the reader wrote and seven they did not. Printing that is worsethan printing nothing. Separating them needs
pathsto carry which module each frame camefrom, which is a change to what
Hit.pathsmeans and belongs in its own change.public, not exported —@experimentalremains the only exported name, and a test says so.🤖 Generated with Claude Code