[ruby-core:92096] Re: [Ruby trunk Misc#15723] Reconsider numbered parameters

From: Martin J. Dürst <duerst@...>
Date: 2019-04-01 23:18:12 UTC
List: ruby-core #92096
On 2019/04/02 01:07, Austin Ziegler wrote:
> In general, I窶冦 OK with this change, but I think that there窶冱 a possible
> scoping issue with these automatic variables that I窶冦 not sure that has
> been considered:
> 
> outer.each {
>    puts @1
>    @1.each {
>      puts @1
>    }
> }
> 
> Elixir doesn窶冲 have this issue because you *can窶冲* declare nested
> declarations this way. But in Ruby, you would no longer have access to the
> outer `@1`.

Maybe that's a feature. Ideally, @1,... are only used for very simple 
cases, and nesting isn't really that simple.

Regards,   Martin.

> I窶冦 not sure what other languages similar to Ruby do.



>> ----------------------------------------
>> Misc #15723: Reconsider numbered parameters
>> https://bugs.ruby-lang.org/issues/15723#change-77387
>>
>> * Author: sos4nt (Stefan Schテシテ殕er)
>> * Status: Feedback
>> * Priority: Normal
>> * Assignee:
>> ----------------------------------------
>> I just learned that *numbered parameters* have been merged into Ruby
>> 2.7.0dev.
>>
>> For readers not familiar with this feature: it allows you to reference
>> block arguments solely by their *index*, e.g.
>>
>> ```ruby
>> [1, 2, 3].each { |i| puts i }
>>
>> # can become
>>
>> [1, 2, 3].each { puts @1 }
>> ```
>>
>> I have an issue with this new feature: I think **it encourages sloppy
>> programming** and results in **hard to read code**.
>>
>> ---

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

In This Thread

Prev Next