Python vs Ruby!

(Kroeger Simon (ext)) #1

> [..snip..]
> Python because of its Perl roots.

I find this somewhat baffling. I'm aware that Matz was influenced by
certain aspects of Perl, but I really don't see any alleged
"Perl roots"
when coding Ruby. (My biased take is that this is something
Pythonitas
like to toss out about any language that allows more than one
way to do
anything.)

At least for someone who never coded Perl, the mere existance
of the following is kind of frightening:

$! $@ $& $+ $` $' $= $1 to $9 $/ $-0 $\ $, $. $; $< $> $_ $-F
$0 $* $" $$ $? $: $-a $-d $F $-i $-I $-K $-l $-p $-v $-w

This reminds me in a sad way of some realy unreadable Makefiles
and is (again, to a non perler) strongly associated with the
coding style of perl. (which may be bogus)

I'm not aware of a single meaning of the above and I have no
intention to change this. (and no need fortunately, if I had
to I wouldn't read this ML)

cheers

Simon

(Austin Ziegler) #2

I've been programming in Ruby for a while now, and I only know the
meanings of $1..$9, $0 (use it all the time -- there's no other
option, as far as I know), $! and $? (only because of shell
programming) and $: (but I usually use $LOAD_PATH). The only one
you'll typically see in my code is $0. And that only for command-line
utility runners.

-austin

···

On 8/19/05, Kroeger Simon (ext) <simon.kroeger.ext@siemens.com> wrote:

At least for someone who never coded Perl, the mere existance
of the following is kind of frightening:

$! $@ $& $+ $` $' $= $1 to $9 $/ $-0 $\ $, $. $; $< $> $_ $-F
$0 $* $" $$ $? $: $-a $-d $F $-i $-I $-K $-l $-p $-v $-w

I'm not aware of a single meaning of the above and I have no
intention to change this. (and no need fortunately, if I had
to I wouldn't read this ML)

--
Austin Ziegler * halostatue@gmail.com
               * Alternate: austin@halostatue.ca

(tony summerfelt) #3

$! $@ $& $+ $` $' $= $1 to $9 $/ $-0 $\ $, $. $; $< $> $_ $-F
$0 $* $" $$ $? $: $-a $-d $F $-i $-I $-K $-l $-p $-v $-w

$!, $_ $0 are my favorites.

I'm not aware of a single meaning of the above and I have no
intention to change this.

well, if you knew perl you'd know what they mean...:slight_smile: you'd also know
they have perfectly acceptable alternative readable names to them also.

my favorites then would be $OS_ERROR, $ARG, and $PROGRAM_NAME,
although i don't think i've ever seen them in real working perl code...

···

Kroeger Simon (ext) wrote on 8/19/2005 4:48 AM: > At least for someone who never coded Perl, the mere existance > of the following is kind of frightening:

--
http://home.cogeco.ca/~tsummerfelt1
telnet://ventedspleen.dyndns.org

(Jim Weirich) #4

I will tend to use $: for one-off scripts because I can never remember if it
is $LOAD_PATH or $LOADPATH. Other than that, I'm with you.

···

On Friday 19 August 2005 07:33 am, Austin Ziegler wrote:

I've been programming in Ruby for a while now, and I only know the
meanings of $1..$9, $0 (use it all the time -- there's no other
option, as far as I know), $! and $? (only because of shell
programming) and $: (but I usually use $LOAD_PATH). The only one
you'll typically see in my code is $0. And that only for command-line
utility runners.

--
-- Jim Weirich jim@weirichhouse.org http://onestepback.org
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)

(Kirk Haines) #5

Austin, if you use the object interface for dealing with regular expressions,
you need not touch $1, $2, $3, etc...

a = 'abc 123 you and me'
my_match = /(\d+)/.match(a)
puts my_match[1]

=> 123

my_match has a MatchData object. Treat it like an array, and index 0 contains
the whole match, while 1 through n contain the captures from the various
parens in the regex. Or you can call #captures to get an array containing
just the captures.

This took a bit longer for me to shift to using over the Perlish $1 .. $9
syntax, because for some quick things, $1 is a lot faster to use than
capturing matchdata and referencing it. Over time, though, I've grown to
prefer it because it just reads better, to me, especially when I start doing
complex things with matches.

Kirk Haines

Kirk Haines

···

On Friday 19 August 2005 5:33 am, Austin Ziegler wrote:

I've been programming in Ruby for a while now, and I only know the
meanings of $1..$9, $0 (use it all the time -- there's no other
option, as far as I know), $! and $? (only because of shell
programming) and $: (but I usually use $LOAD_PATH). The only one
you'll typically see in my code is $0. And that only for command-line
utility runners.

(Austin Ziegler) #6

I know. That's why you won't see $1 .. $9 in my code. :wink:

-austin

···

On 8/19/05, Kirk Haines <khaines@enigo.com> wrote:

On Friday 19 August 2005 5:33 am, Austin Ziegler wrote:
> I've been programming in Ruby for a while now, and I only know the
> meanings of $1..$9, $0 (use it all the time -- there's no other
> option, as far as I know), $! and $? (only because of shell
> programming) and $: (but I usually use $LOAD_PATH). The only one
> you'll typically see in my code is $0. And that only for command-line
> utility runners.
Austin, if you use the object interface for dealing with regular expressions,
you need not touch $1, $2, $3, etc...

--
Austin Ziegler * halostatue@gmail.com
               * Alternate: austin@halostatue.ca

(David A. Black) #7

Hi --

···

On Sat, 20 Aug 2005, Austin Ziegler wrote:

On 8/19/05, Kirk Haines <khaines@enigo.com> wrote:

On Friday 19 August 2005 5:33 am, Austin Ziegler wrote:

I've been programming in Ruby for a while now, and I only know the
meanings of $1..$9, $0 (use it all the time -- there's no other
option, as far as I know), $! and $? (only because of shell
programming) and $: (but I usually use $LOAD_PATH). The only one
you'll typically see in my code is $0. And that only for command-line
utility runners.

Austin, if you use the object interface for dealing with regular expressions,
you need not touch $1, $2, $3, etc...

I know. That's why you won't see $1 .. $9 in my code. :wink:

Let's be fair, though. It's $1 to $n :slight_smile:

David

--
David A. Black
dblack@wobblini.net

(Kirk Haines) #8

Hah. Sorry. After I sent the message it occured to me that I probably
misinterpreted you. :slight_smile:

Kirk

···

On Friday 19 August 2005 9:16 am, Austin Ziegler wrote:

> Austin, if you use the object interface for dealing with regular
> expressions, you need not touch $1, $2, $3, etc...

I know. That's why you won't see $1 .. $9 in my code. :wink:

(Matt Lawrence) #9

In the interest of m18n, shouldn't that be USD1 to USDn?

-- Matt
Nothing great was ever accomplished without _passion_

···

On Sat, 20 Aug 2005, David A. Black wrote:

I know. That's why you won't see $1 .. $9 in my code. :wink:

Let's be fair, though. It's $1 to $n :slight_smile: