1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/lib
Jeremy Evans 3b302ea8c9 Add Module#ruby2_keywords for passing keywords through regular argument splats
This approach uses a flag bit on the final hash object in the regular splat,
as opposed to a previous approach that used a VM frame flag.  The hash flag
approach is less invasive, and handles some cases that the VM frame flag
approach does not, such as saving the argument splat array and splatting it
later:

  ruby2_keywords def foo(*args)
    @args = args
    bar
  end
  def bar
    baz(*@args)
  end
  def baz(*args, **kw)
    [args, kw]
  end
  foo(a:1)    #=> [[], {a: 1}]
  foo({a: 1}, **{}) #=> [[{a: 1}], {}]

  foo({a: 1}) #=> 2.7: [[], {a: 1}] # and warning
  foo({a: 1}) #=> 3.0: [[{a: 1}], {}]

It doesn't handle some cases that the VM frame flag handles, such as when
the final hash object is replaced using Hash#merge, but those cases are
probably less common and are unlikely to properly support keyword
argument separation.

Use ruby2_keywords to handle argument delegation in the delegate library.
2019-09-25 12:33:52 -07:00
..
bundler
cgi
csv
drb
e2mmap
fileutils
forwardable
irb
logger
matrix
net
optparse
racc
rdoc
reline
rexml
rinda
rss
rubygems Make rb_scan_args handle keywords more similar to Ruby methods (#2460) 2019-09-25 11:18:49 -07:00
tracer
unicode_normalize
uri
webrick
yaml
.document
abbrev.rb
base64.rb
benchmark.rb
bundler.rb
cgi.rb
csv.rb Make rb_scan_args handle keywords more similar to Ruby methods (#2460) 2019-09-25 11:18:49 -07:00
debug.rb
delegate.rb Add Module#ruby2_keywords for passing keywords through regular argument splats 2019-09-25 12:33:52 -07:00
drb.rb
e2mmap.rb
English.rb
erb.rb
fileutils.rb Make rb_scan_args handle keywords more similar to Ruby methods (#2460) 2019-09-25 11:18:49 -07:00
find.rb
forwardable.rb
getoptlong.rb
ipaddr.gemspec
ipaddr.rb
irb.rb
logger.rb
matrix.rb
mkmf.rb
monitor.rb
mutex_m.gemspec
mutex_m.rb
observer.rb
open-uri.rb Make rb_scan_args handle keywords more similar to Ruby methods (#2460) 2019-09-25 11:18:49 -07:00
open3.rb
optionparser.rb
optparse.rb
ostruct.gemspec
ostruct.rb
pp.rb
prettyprint.rb
prime.gemspec
prime.rb
pstore.rb Make rb_scan_args handle keywords more similar to Ruby methods (#2460) 2019-09-25 11:18:49 -07:00
racc.rb
rdoc.rb
readline.rb
reline.rb
resolv-replace.rb
resolv.rb
rss.rb
rubygems.rb
securerandom.rb
set.rb
shellwords.rb
singleton.rb
tempfile.rb Make rb_scan_args handle keywords more similar to Ruby methods (#2460) 2019-09-25 11:18:49 -07:00
time.rb
timeout.rb
tmpdir.rb
tracer.rb
tsort.rb
un.rb
uri.rb
weakref.rb
webrick.rb
yaml.rb