r/programming • • Feb 24 '13

Ruby 2.0.0

http://www.ruby-lang.org/en/news/2013/02/24/ruby-2-0-0-p0-is-released/
600 Upvotes

193 comments sorted by

View all comments

Show parent comments

4

u/madmars Feb 24 '13

sounds exactly like what people do in Perl to pass parameters, which is a huge pet peeve of mine:

doSomething( argument => 'whatever' );

Then if someone goofs...

doSomething( argrument => 'whatever' );

Then you're proper fucked. I spend nearly an hour one day, tracking down this stupid bug because someone had a lowercase letter where an uppercase letter should have been. I started making it a point to do:

sub doSomething {
    my @required = qw(required1 required2 ...);
    my @optional = qw(optional1 optional2 ...);
    # check input against both required and optional...
}

However this is tedious, since you have to check...

  • Required parameters. Ensure all of these are passed.

  • Parameters passed which are neither in required or optional

The last check is important, otherwise you won't catch misspellings and parameters that people just assume work with the subroutine but actually do not.

1

u/lobster_johnson Feb 24 '13

I thought Perl had keyword args — or is that just Perl 6? (Isn't Perl 6 the "current" version yet?)

3

u/madmars Feb 24 '13

Perl 6 might. I don't keep up with it. Perl 5 is largely considered "the" Perl, which is what the "modern Perl" movement is based on. If you find any Perl software or any company looking for Perl developers, it's almost certainly going to be version 5.

6 is so different that they should have just picked a new name, rather than use Perl. But that's just my opinion.

0

u/lobster_johnson Feb 24 '13

According to Wikipedia, you're right, and Perl 6 is still in limbo. Too bad; I dislike Perl, but what has happened to it seems unfortunate.