From: Matthew Kerwin Date: 2014-02-01T09:22:59+10:00 Subject: [ruby-core:60392] Re: [ruby-trunk - Feature #8987] map/collect extension which handles arguments --001a11c3f2b46efdd804f14c746d Content-Type: text/plain; charset=ISO-8859-1 On Jan 31, 2014 6:20 PM, wrote: > > Actually I believe the most readable form would be > > `p [1,2,3,4].map{ 4 + _ } # when there is no |...|, set block params to _ ` > > Many blocks in realworld-code are so easy, that it is really a barrier to have to think about a name, and therefore one uses often non-verbose names like you used x. Where is the point in being forced to think of a name, when you don't set the name to something meaningful. I guess this was the idea why the to_proc convention was introduced. The problem with it is, that it is really limiting because you cannot use parameters (and the presence of a parameter doesn't necessarily make problems so complex to justify a name). I guess you can solve it by syntax or by convention. I've, personally, never had a pause when calling it 'x' or 'item', depending on the context. You could also develop the convention of: arr.map{|_| ... } My only problem with magic variables is that I can never remember when they get (re)assigned. It's particularly annoying in perl, because those guys never assign a variable when $_ will suffice. Matthew Kerwin --001a11c3f2b46efdd804f14c746d Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

On Jan 31, 2014 6:20 PM, <sowieso= @dukun.de> wrote:
>
> Actually I believe the most readable form would be
>
> `p [1,2,3,4].map{ 4 + _ }  # when there is no |…|, set blo= ck params to _ `
>
> Many blocks in realworld-code are so easy, that it is really a barrier= to have to think about a name, and therefore one uses often non-verbose na= mes like you used x. Where is the point in being forced to think of a name,= when you don't set the name to something meaningful. I guess this was = the idea why the to_proc convention was introduced. The problem with it is,= that it is really limiting because you cannot use parameters (and the pres= ence of a parameter doesn't necessarily make problems so complex to jus= tify a name).

I guess you can solve it by syntax or by convention. I've, personall= y, never had a pause when calling it 'x' or 'item', dependi= ng on the context. You could also develop the convention of: arr.map{|_| ..= . }

My only problem with magic variables is that I can never remember when t= hey get (re)assigned. It's particularly annoying in perl, because those= guys never assign a variable when $_ will suffice.

Matthew Kerwin

--001a11c3f2b46efdd804f14c746d--