Re: Perl Object Creation problem...
- From: Stephan Titard <sgt19@xxxxxx>
- Date: Fri, 30 Jun 2006 13:17:07 +0200
howa escribió:
Tad McClellan 寫道:hi, well
howa <howachen@xxxxxxxxx> wrote:lawre...@xxxxxxxxxxxxxxxxxxx ???
"howa" <howachen@xxxxxxxxx> writes:it seems a little stupid if the class name must be the package fullPerhaps this will offer enlightenement:
name...
Suppose I have two classes Road::Apple and Fruit::Apple
#/usr/local/bin/howas-private-perl-like-language
use Road::Apple;
use Fruit::Apple;
my $thing = new Apple;
What kind of apple whould $thing be?
I don't think that was a rhetorical question, but you did not
address it.
What kind of apple whould $thing be?
One is delicious, the other not
so much.
[snip .sig, you are not supposed to quote those you know]
in other language, you also have this problem, java or c.^^^^
What is with the "also" there?
Perl does not have that problem.
in fact, this is not a problem at all,
Then what kind of apple whould $thing be?
A red one or a brown one?
If the programmer cannot tell, then it looks like a problem to me...
--
Tad McClellan SGML consulting
tadmc@xxxxxxxxxxxxxx Perl programming
Fort Worth, Texas
did you even have experience on java or c? (no offense)
how they handle namespace/package/import/include ?
of coz perl has more then one way to do it, but seems the way how perl
handle it is not a good solution.
given a problem that could affect many languages the solution depends on the language and it might even be that the problem disappears for some language...
the import mecanism in java is there so that essentially you don't have to type long names, in perl it is not really necessary
for example, the java snippet
import org.vln.*
VeryLongName v = new VeryLongName();
in perl
you save at least the lhs part ;)
my $v = org::vln::VeryLongName->new() ; # better to stick to the arrow...
Also from the point of view of explicit documentation/maintainability I must prefer to use the full name.
anyway if you really want a short name you can use an alias
via one of the alias modules on CPAN
o use typeglob assignment (which you can read as a way of saying that 2 namespaces are equivalent)
*VLN = *Very::Long::Name;
in the context of OO I use it very little
preferring to hide this behing a module
now perl as a dynamic language has a lot more to offer
you can say
my $class = 'Very::Long::Name';
and
my $v = $class->new;
if you wish
o act on a series of classes
for my $class (@these_classes_that_do_survey_of_the worldcup)
{
my $watcher = $class->new();
$watcher->watch_football();
$watcher->save_result();
}
hth
--stephan
.
- References:
- Perl Object Creation problem...
- From: howa
- Re: Perl Object Creation problem...
- From: Aukjan van Belkum
- Re: Perl Object Creation problem...
- From: howa
- Re: Perl Object Creation problem...
- From: Brian McCauley
- Re: Perl Object Creation problem...
- From: howa
- Re: Perl Object Creation problem...
- From: lawrence
- Re: Perl Object Creation problem...
- From: howa
- Re: Perl Object Creation problem...
- From: Tad McClellan
- Re: Perl Object Creation problem...
- From: howa
- Perl Object Creation problem...
- Prev by Date: Re: Question on printerhandling
- Next by Date: Re: Cam::PDF question
- Previous by thread: Re: Perl Object Creation problem...
- Next by thread: Re: Perl Object Creation problem...
- Index(es):
Relevant Pages
|
|