[ale] What to use

Fletch fletch at phydeaux.org
Wed Apr 23 09:44:25 EDT 2003



On Tue, 2003-04-22 at 15:25, Joseph Knapka wrote:

> # Call doSomthing 3 times

<pedant> Technically these three are subtly different.  See perlsub
for the full details, but: 


> &doSomething;

This calls doSomething, but passes the current sub's args (@_).

#!/usr/bin/perl
sub bar { print "bar: ", join( ", ", @_ ) }
sub foo { &bar; }

foo( qw( Zorch bippy acorn ) );
__END__


> doSomething();

This calls doSomething, but passes no arguments (@_ will be empty).


> doSomething;

This calls doSomething with no arguments, but the definition for the
sub has to have been seen before the call (so that perl knows it's a
sub and not a bareword; of course if you've `use strict'd like you
should perl would then scream at you for the bareword . . .).


> To me that is the #1 weakness of the language. The lack of a clear
> standard way of doing things.  When you go to perl from a structured
> language, it kinda confuses you. :)

Ah, but the thing is you can be as structured as you want.  Or not.
TMTOWTDI.  But it's your choice, not the language's, as which way you
go.


At any rate, before this devolves into a dissertation on why Python
blows :) I'll point you at _Object Oriented Perl_ by Damian Conway for
an excellent guide on being structured and OOP-y in perl, and at
http://www.ruby-lang.org/en/ for a bit more regular alternative to
perl (think Perl cross Smalltalk with some of the good ideas from
Python swiped for good measure; Ruby's purported to be a heavy
influence on how perl6 is shaping up)

-- 
Fletch                | "If you find my answers frightening,       __`'/|
fletch at phydeaux.org   |  Vincent, you should cease askin'          \ o.O'
770 294-0820 (m)      |  scary questions." -- Jules                =(___)=
                      |                                               U
_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale





More information about the Ale mailing list