Issue #15078 has been updated by mame (Yusuke Endoh).


Marc-Andre,

marcandre (Marc-Andre Lafortune) wrote:
> * Proposed semantics *

I thought it looked good.  However, I introduced it to some committers at the developers' meeting, and akr-san showed it was still incomplete:

```
def target(*args)
  p args
end

def forward(*args, **kw, &blk)
  target(*args, **kw, &blk)
end

target(1, 2, 3, {})  #=> [1, 2, 3, {}]
forward(1, 2, 3, {}) #=> [1, 2, 3] on the semantics you proposed ([1, 2, 3, {}] on the current behavior)
```

Akr-san said that it would be impossible to create a "perfect" semantics to satisfy all cases.  In Ruby 2.X, he said that `**empty_hash` should be just ignored, and that `foo({}, **{})` should be always equal to `foo({})`, even if `def foo(opt=42, **kw)` receives `opt=42`.  (However, matz showed reluctance to this behavior.  So, the solution for this ticket is not decided yet.)

Also, akr-san and some committers agreed with my proposal of "real" keyword arguments to solve all the kind of design flaws.  (Surprisingly, there was no committer there who was against my proposal, even though it breaks compatibility.  Matz also looked positive, but he has not made the decision yet.)
It would be impossible to write a delegation code that works perfectly on both 2.X and 3.0, but it would work good enough on almost all practical cases, akr-san said.

Akr-san and some committers said that a hash or keyword should be decided syntactically based on `=>` or `:`.  `foo(key: 1) should pass a keyword and `foo(:key => 1)` should pass a hash (i.e., `foo({:key => 1})`).  I'll consider it and update my proposal.

----------------------------------------
Bug #15078: Hash splat of empty hash should not create a positional argument.
https://bugs.ruby-lang.org/issues/15078#change-74035

* Author: marcandre (Marc-Andre Lafortune)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 
* ruby -v: ruby 2.6.0dev (2018-08-27 trunk 64545) [x86_64-darwin15]
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
Looks like #10856 is not completely fixed, but I can't reopen it

```
def foo(*args); args; end
foo(**{}) # => []
foo(**Hash.new) # => [{}], should be []
```



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>