Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion inheritance problem

From: Ren Maddox <ren.mad...@tivoli.com>
Subject: Re: inheritance problem
Date: 2000/09/27
Message-ID: <m3snqlrhlb.fsf@dhcp11-177.support.tivoli.com>#1/1
X-Deja-AN: 674738840
Approved: mjd-clpm-ad...@plover.com
Sender: mjd-clpm-ad...@plover.com
References: <39D1ACBD.35A159A6@dial.pipex.com>
X-Original-NNTP-Posting-Host: dhcp11-177.support.tivoli.com
X-Complaints-To: usenet@tivoli.com
X-Trace: news.tivoli.com 970067962 2285 10.69.11.177 (27 Sep 2000 15:19:22 GMT)
Organization: Tivoli Systems Inc., Austin TX
NNTP-Posting-Date: 27 Sep 2000 15:19:22 GMT
Newsgroups: comp.lang.perl.moderated

Technical Services - UK Link <f...@dial.pipex.com> writes:

> I have a number of modules that have a structure like the example below,
> the problem I have with them is that when I call Test1->testing, it
> should call Test2->new which in turn should call Test1->new, but for
> some reason it only calls Test1->new, can anyone explain to me why this
> is happening and tell me what I can do about it?

I believe you are running into a problem with your indirect object
syntax.  If you change the call to new as I have indicated, you will
get the desired behavior.  With the indirect object syntax, I believe
that $module is being interpreted as a simple argument to the "new"
function in the current package (Test1).  All-in-all, it seems best to
simply avoid the indirect object syntax.

The latest Camel has this to say about the indirect object syntax:

"The indirect object syntax is less cluttered, but suffers from
several forms of syntactic ambiguity."

It goes on to list two particular ambiguities, neither of which seems
to explain the behavior you are seeing, but I take that as staunch
enough warning to simply avoid the syntax whenever possible.

[code omitted]
> sub testing {
>    my $module = 'Test3';
> 
>    require "$module.pm";
>    import $module;
> 
>    # This should call Test2::new which then calls Test1::new,
>    #  but Test2::new never seems to be called.
>    my $test3 = new $module;
     my $test3 = $module->new;
> }
[more code omitted]

-- 
Ren Maddox
r...@tivoli.com