Skip to content
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

Fix invalidations from Pair(obj) methods #2695

Merged
merged 1 commit into from
Aug 11, 2021
Merged

Fix invalidations from Pair(obj) methods #2695

merged 1 commit into from
Aug 11, 2021

Conversation

timholy
Copy link
Member

@timholy timholy commented Aug 11, 2021

xref sbromberger/LightGraphs.jl#1581

These are mostly julia#15276-related, with some julia#36454 thrown in for good measure.

@timholy
Copy link
Member Author

timholy commented Aug 11, 2021

CC @ChrisRackauckas

@timholy timholy merged commit b1ec6de into master Aug 11, 2021
@timholy timholy deleted the teh/pair_invalid branch August 11, 2021 17:12
@KristofferC
Copy link
Member

I'll just never use a do block again :)

@timholy
Copy link
Member Author

timholy commented Aug 12, 2021

do blocks are wonderful, so I'd say use 'em if you want. julia#15276 is a bummer for sure, but we should just write some tooling to detect Core.Box automatically. I'm thinking of using it as an excuse to learn some JET internals (aviatesk/JET.jl#233) but truth be told it would be super-easy to add this to MethodAnalysis (just a couple of lines).

@KristofferC
Copy link
Member

do blocks are wonderful,

Okay, so let's look at do blocks. In order to clean up a resource after a scope a do block:

  • Causes one extra indentation (per object!).
  • Requires a tool to find all the cases where it leads to bad type inference and in those cases it causes and extra level of indentation (the let part).
  • Gives the code inside the do part different semantics (return behaves differently).
  • Makes the code hard to step through in the debugger
  • Requires a closure to be created with some gensymmed named, making it hard to precompile

If this wasn't an stdlib I would immediately get rid of every LibGit2.with and replace it with https://github.com/adambrewster/Defer.jl. No scopes, no indentation, no different semantics. Just run a function after scope exits. Exactly what is required.

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.

2 participants