in reply to Re: Writing Object-Orientated Module: use of “new” and other methods.
in thread Writing Object-Orientated Module: use of “new” and other methods.
sub new { die "main::new sub called" } sub Foo { die "main::Foo sub called" } # can't use Foo->new here!!!!!!!!!!! $obj = new Foo:: ; print "Got $obj\n"; package Foo; sub new { return bless [] => shift(); }
That will correctly print out Got Foo=ARRAY(0x7ec91370). There is no ambiguity: you just have to do it right, that’s all. That said, it’s no fun to chain them.
And by the way, the mechanism you used won’t work in the code above. Your style can be just as buggy as what you’re worried about people doing by using dative syntax. If you don’t want to use the package-quoted dative syntax of new Foo::, you still must use Foo::->new and not Foo->new, because otherwise you’ll still bomb out. Please try it with the commented-out line to see what I mean.
And here’s another:my $sorter = new Unicode::Collate:: upper_before_lower => 1, preprocess => \&reduce_for_sorting, entry => deQ<<'END_OF_OVERRIDE', |Q| |Q| 005B 006E 002E ; [.0200.0020.0002.0391] # [n. |Q| 005B ; [.0220.0020.0002.0392] # [ |Q| 005D ; [.0225.0020.0002.0395] # ] |Q| END_OF_OVERRIDE ;
See how nice and legible that is when written that way? And there really and truly is no ambiguity — unlike with your code, where there is.state $formatter = new Unicode::LineBreak:: Context => "NONEASTASIAN", ColumnsMax => 80, ColumnsMin => 8, Format => "SIMPLE", SizingMethod => \&tabbed_sizing, TailorLB => [ ord("\t") => LB_SP, LEFT_QUOTES() => LB_OP, RIGHT_QUOTES() => LB_CL, ], ;
PS: I see my stalker is quick to the draw. Yawn!
- Comment on Re^2: Writing Object-Orientated Module: use of “new” and other methods.
- Select or Download Code