in reply to Creating new objects from within a package
The first use of 'new' appears before the 'new' sub has been compiled, so perl doesn't know about it yet. It assumes that 'new T' must be an indirect method call on the 'T' class. In the second case, 'new' now exists in the symbol table, so perl assumes you're calling the function 'new' with the parameter 'T', which is a bareword.$ perl -MO=Deparse -e 'sub new { new T } sub s1 { new T }' sub new { 'T'->new; } sub s1 { new 'T'; }
Dave.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Creating new objects from within a package
by hawtin (Prior) on Jul 22, 2004 at 07:46 UTC |