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

Support keyword arguments on all Concurrent Struct classes #738

Conversation

numeraltwo
Copy link

@numeraltwo numeraltwo commented Jul 6, 2018

📓 Original issue: #694

⚠️ Putting this up for initial comments, there's still one tiny bit to address which I will complete shortly...

(fix #694)

@pitr-ch
Copy link
Member

pitr-ch commented Jul 6, 2018

Awesome! Let me know when I can have a look.

@pitr-ch pitr-ch changed the title Support keyword arguments on all Concurrent Struct classes Support keyword arguments on all Concurrent Struct classes fix: #694 Jul 6, 2018
@pitr-ch pitr-ch changed the title Support keyword arguments on all Concurrent Struct classes fix: #694 Support keyword arguments on all Concurrent Struct classes Jul 6, 2018
@ghost ghost added the in progress label Jul 7, 2018
@numeraltwo
Copy link
Author

@pitr-ch 👌 – this would definitely make MRI > 2 and other analogues a requirement – otherwise SyntaxError due to unexpected tPOW.

Also if all looks good I'll squash the commit history 👍

@pitr-ch
Copy link
Member

pitr-ch commented Jul 7, 2018

I've just merged #740, could you rebase on master? Squashing is not necessary.

@numeraltwo numeraltwo force-pushed the keyword_parameters_for_structs branch from 67c3c5a to 06f8a02 Compare July 7, 2018 22:16
@numeraltwo
Copy link
Author

@pitr-ch all set.

Copy link
Member

@pitr-ch pitr-ch left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks. I had few miner suggestions for improvement, please have a look.

@@ -71,20 +71,20 @@ def select(&block)
end

# @!macro struct_new
def self.new(*args, &block)
def self.new(*args, **kw_args, &block)
Copy link
Member

Choose a reason for hiding this comment

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

It would be better to have the signature more specific def self.new(*args, keyword_init: false, &block). Afaik no other keyword argument has any effect.

@@ -197,20 +197,20 @@ def []=(member, value)
end

# @!macro struct_new
Copy link
Member

Choose a reason for hiding this comment

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

Please update the struct_new definition to include documentation about keyword_init option.

ns_initialize(*values, **kw_values)
end

# @!macro [attach] struct_keyword_init
Copy link
Member

Choose a reason for hiding this comment

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

The macro definition at the beginning of the can doc can be omitted, if the doc is not shared with other methods.

#
# @return [Boolean] true if struct uses keyword arguments
def keyword_init?
self.class::KEYWORD_INIT
end
Copy link
Member

Choose a reason for hiding this comment

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

The keyword_init? on struct instance probably has not usage other then the initialization, I think it can be omitted or moved to the struct class replacing the KEYWORD_INIT constant.

@pitr-ch
Copy link
Member

pitr-ch commented Aug 21, 2018

@numeraltwo friendly reminder :)

@pitr-ch pitr-ch added this to Nope in Hackathon Aug 24, 2019
@chrisseaton
Copy link
Member

Closing both due to inactivity, and also because there's a proper way to delegate keyword arguments now. Please do re-engage if you still want to work on it.

ruby-concurrency/concurrent-ruby automation moved this from In Progress to Done Jan 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Keyword parameters for MutableStruct in Ruby 2.5.0
3 participants