Skip to content

Conversation

@michael-schwarz
Copy link
Member

@michael-schwarz michael-schwarz commented Feb 18, 2025

Using map_default, map_default_delayed, and friends makes the code much more concise.

@michael-schwarz michael-schwarz added the cleanup Refactoring, clean-up label Feb 18, 2025
Copy link
Member

@sim642 sim642 left a comment

Choose a reason for hiding this comment

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

This simplifies some uses but I'm unsure about others.
In particular, replacing some matches with large bodies with Option.map_default (or similar) sometimes moves what's being matched much further down (after the lambda). This might hurt readability because the code doesn't read top-down as it executes.

I think it would be good for someone else to also have a look with this in mind to see if they also get this impression.

michael-schwarz and others added 2 commits February 19, 2025 10:59
Co-authored-by: Simmo Saan <[email protected]>
Co-authored-by: Simmo Saan <[email protected]>
@michael-schwarz
Copy link
Member Author

What is our plan here? Which ones do we want to merge and what do we want to close?

@sim642 sim642 requested a review from arkocal July 23, 2025 14:55
@arkocal
Copy link
Contributor

arkocal commented Jul 29, 2025

Apart from Simmo's open questions I would take this as is, it is in general a good improvement.

Out-of-scope for this PR, but somehow related:
The parts where I have most difficulty reading are large branches in match statements of large functions in Option functions. Without knowing the logic well they are pretty much impossible to read either way (match etc vs. option). I would much prefer functions with descriptive names over lambdas in those cases.

  • this allows us to see the map and the default value (or similar) at one glance.

@michael-schwarz michael-schwarz requested a review from sim642 July 29, 2025 10:53
@sim642 sim642 added this to the v2.6.0 Awkward Aardvark milestone Jul 31, 2025
@michael-schwarz michael-schwarz merged commit 306952d into master Jul 31, 2025
17 checks passed
@michael-schwarz michael-schwarz deleted the option_cleanup branch July 31, 2025 08:20
michael-schwarz added a commit that referenced this pull request Jul 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cleanup Refactoring, clean-up

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants