- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13
feat!: Hide FuncDefn/cl fields, add accessors and ::new(...) #2213
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
Conversation
| /// Create a new instance with the given name and signature | ||
| pub fn new(name: impl Into<String>, signature: impl Into<PolyFuncType>) -> Self { | 
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.
Couldn't we just add new_public now, since it's what it's effectively doing?
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.
I think new is the right move now since the semantics of "public" are not defined yet, we can deprecate it when adding new_public and new_private which will indicate downstream that changes are required because linters will complain (even though it will be non-breaking)
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.
I don't think it is. Quite a lot of code (e.g. dataflow analyses) takes an explicit list of entry points rather than assuming functions are public/private. Moreover, public functions not child of the Module, will likely become illegal...
Seyon suggests that we can deprecate this when adding new_private/new_public, which sounds good to me.
| This PR contains breaking changes to the public Rust API. cargo-semver-checks summary | 
| I'm not really persuaded about hiding  | 
| No, if there's at least one private field then  | 
        
          
                hugr-core/src/ops/module.rs
              
                Outdated
          
        
      | &self.name | ||
| } | ||
|  | ||
| /// Sets the name of the function (as per [Self::func_name]) | 
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.
| /// Sets the name of the function (as per [Self::func_name]) | |
| /// Allows mutating the name of the function (as per [Self::func_name]) | 
        
          
                hugr-core/src/ops/module.rs
              
                Outdated
          
        
      | } | ||
| } | ||
|  | ||
| /// The name of the function (not, the name of the Op) | 
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.
| /// The name of the function (not, the name of the Op) | |
| /// The name of the function (not the name of the Op) | 
| /// The name of the function (not, the name of the Op) | ||
| pub fn func_name(&self) -> &String { | ||
| &self.name | ||
| } | 
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.
matching func_name_mut?
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.
Yeah, so this lead to spotting #2215
| Codecov ReportAttention: Patch coverage is  
 Additional details and impacted files@@            Coverage Diff             @@
##             main    #2213      +/-   ##
==========================================
- Coverage   82.10%   82.00%   -0.10%     
==========================================
  Files         230      230              
  Lines       40943    40940       -3     
  Branches    37044    37041       -3     
==========================================
- Hits        33616    33574      -42     
- Misses       5363     5398      +35     
- Partials     1964     1968       +4     
 Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
 | 
Accessors ::func_name, ::func_name_mut, ::signature, ::signature_mut.
Constructor ::new takes name + sig using
impl Into.BREAKING CHANGE: construction, destruction, and field access should use new methods