From: "zverok (Victor Shepelev) via ruby-core" <ruby-core@...> Date: 2024-12-16T15:24:45+00:00 Subject: [ruby-core:120262] [Ruby master Bug#20955] Subtle differences with Proc#parameters for anonymous parameters Issue #20955 has been updated by zverok (Victor Shepelev). @bkuhlmann The only possible reason is not to confuse with this: ```ruby proc { |it| }.parameters # the parameter is literally named "it" ``` I am not sure it matters much, but maybe in somebody���s metaprogramming... I don���t remember seeing libraries in Ruby that changed behavior depending on parameter names (and changing it on parameter name `it` seems even less plausible), but theoretically, it _could_ happen. (The situation is unlike `_1`, which is NOT allowed to be an explicit parameter name.) ---------------------------------------- Bug #20955: Subtle differences with Proc#parameters for anonymous parameters https://bugs.ruby-lang.org/issues/20955#change-111028 * Author: zverok (Victor Shepelev) * Status: Open * ruby -v: ruby 3.4.0dev (2024-12-15T13:36:38Z master 366fd9642f) +PRISM [x86_64-linux] * Backport: 3.1: DONTNEED, 3.2: DONTNEED, 3.3: DONTNEED ---------------------------------------- ```ruby p proc { |x| }.parameters #=> [[:opt, :x]] p lambda { |x| }.parameters #=> [[:req, :x]] p proc { _1 }.parameters #=> [[:opt, :_1]] p lambda { _1 }.parameters #=> [[:req, :_1]] p proc { it }.parameters #=> [[:opt, nil]] p lambda { it }.parameters #=> [[:req]] ``` Note the last pair; here are two small confusing problems: 1. For proc, unlike numbered parameters, the parameter name is `nil` (not `it`). This, though, can be justified to distinguish from `proc { |it| }` case 2. But also, `proc` has this `nil` for a parameter name, while `lambda` has not. I am not sure what the ���most logical��� thing to do here, but I believe that at least `proc { it }` and `lambda { it }` should be made consistent with each other. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/