On 06.06.2011 16:57, David Masover wrote:
> On Monday, June 06, 2011 03:35:30 AM Ilias Lazaridis wrote:
>>> That reminds me Groovy's it.
>>
>> I don't know "Groovy", but I dislike the "it", as it cannot be spoken
>> like "each item" or "each value".
>>
>> I've just noticed repetitions within code like that:
>>
>> names.each { |name| puts name} # 3 times "name(s)"
>>
>> names.each { puts item }
>>
>> names.each { puts e) # e = entry
>>
>>> Currently I have no plan to change the core like that.
>>
>> So this would be a low-priority issue?
>>
>> Would a thoroughly worked out patch be accepted?
>
> I'm not sure that I have a vote, but I'd also vote against.

Why wouldn't you?  (Whether our votes are counted somewhere is a 
different question though.) ;-)

> I like the
> motivation, and that's why we have clever hacks like Symbol#to_proc:
>
> names.map(&:to_s)

<snip>Lots of good reasoning</snip>

> I don't really see a good way to make this work.
>
>
>
> One of the more interesting features of Perl is the default variable, $_ --
> most builtin functions will automatically default to this if you don't provide
> an explicit variable. It certainly prevents some repetitive code, makes some
> things seem shorter and cleaner, and it seems pretty cool. But then you end up
> with code like this:
>
> while(<STDIN>) {
>      chomp;
>      print "$1\n" if /^Hello, (.*)/;
> }
>
> ..and that's a short, mostly-readable example because I frankly don't
> remember enough about Perl to make it really dangerous. Even so, look at how
> twisted it is already. If you're not a Perlist already, it's not obvious that
> "while(<STDIN>)" actually loops over each line of standard input. Once you get
> that, you might figure out that chomp and the regex should apply to these
> lines, but it's much more common to find a somewhat larger loop body, with
> actual variables mixed and matched with automagic ones.

That's because Perl got OO retrofitted later - in a bad way.  (Well, 
there was probably no other choice given the language as it was at the 
time.)  Ah, how much nicer is the clean OO of Ruby!

> And that's only one kind of default variable, and there are all sorts of other
> variables Perl magically defines for you. Ruby's borrowed a few of them, but
> they're all well-defined by now, and generally obviously 'special' in some
> way, like __FILE__ and $1.

Ironically $_ is one of them. :-)

$ seq 1 5 | ruby19 -ne 'p $_'
"1\n"
"2\n"
"3\n"
"4\n"
"5\n"

$

> Sometimes, verbosity is good. I'd much rather do a little extra typing from
> time to time than have Perl-like black magic going on behind the scenes.

+1

Kind regards

	robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/