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

Improve get() method shadowing #182

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ndortega
Copy link
Member

@ndortega ndortega commented Apr 4, 2024

  • Added a default get() function to pass through other calls to the Base.get function

Copy link

codecov bot commented Apr 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.36%. Comparing base (82fdc0e) to head (d741ba5).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #182   +/-   ##
=======================================
  Coverage   99.36%   99.36%           
=======================================
  Files          24       24           
  Lines        1266     1267    +1     
=======================================
+ Hits         1258     1259    +1     
  Misses          8        8           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ndortega
Copy link
Member Author

ndortega commented Apr 4, 2024

@JanisErdmanis Here's the changes you brought up

@JanisErdmanis
Copy link
Contributor

The test set looks good. Perhaps it could be improved with a case when package which depends on Oxygen is loaded as a module to check if there are any precompilation errors. I think that can be automated by creating a dummy package which can be put within a test directory and added to a LOAD_PATH which would then be treated as ordinary package with precompilation.

@JanisErdmanis
Copy link
Contributor

@ndortega can we also add a method:

get(collection, key) = Base.get(collection, key)

Since users or package developers may want to overload get method this way. Perhaps even safer strategy here is:

get(args...) = Base.get(args...)
get(args...; kwargs...) = Base.get(args...; kwargs...)

@JanisErdmanis
Copy link
Contributor

JanisErdmanis commented Apr 11, 2024

We need to comment out in Oxygen.jl with this pull request:

import Base: get

Because otherwise we have

import Base: get
get(x, y, z) = Base.get(x, y, z)

and thus if method is not found it would form a recursion. The removal of import Base: get is also good as that eliminates type piracy.

An alternative is putting the redirection get methods within the @oxidise macro itself.

@ndortega ndortega marked this pull request as draft September 6, 2024 12:41
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