in reply to OO style: Placement of "new"
For example, calling a method new in indirect notation--as C++ programmers are so wont to do--can be miscompiled into a subroutine call if there's already a new function in scope.Perhaps someone can demonstrate how to cause this to happen. I've been using indirect notation for several years now, in 5.005, 5.6, and now 5.8, and have never once seem the wrong subroutine invoked.
Here's a starting point. Can someone morph this into something that fails?
Anything that fails to print "Foo" constitutes failure.package Foo; sub new { print "Foo\n"; bless {} } package Bar; sub new { print "Bar\n"; bless {} } sub addFoo { my $self = shift; $self->{Foo} = new Foo(); # which new gets invoked? } package main; my $bar = new Bar(); $bar->addFoo(); # if there's a bug, this should tickle it
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: OO style: Placement of "new" (easy)
by tye (Sage) on Apr 08, 2003 at 05:05 UTC | |
by dws (Chancellor) on Apr 08, 2003 at 05:28 UTC | |
by tye (Sage) on Apr 08, 2003 at 05:58 UTC | |
|