in reply to Re^3: Is it ok to mix functional and oo programming in one package?
in thread Is it ok to mix functional and oo programming in one package?
The key words in "method invocation using the METHOD CLASS_OR_INSTANCE LIST form is exactly equivalent to CLASS_OR_INSTANCE->METHOD (LIST) form." are "method invocation".
In other words, if new Foo is resolved by the perl parser as a method call it is exactly equivalent. The problem is that it isn't always. For instance, this works:
output:#!/usr/bin/perl use warnings; use strict; my $a = new Foo; $a->hello; package Foo; sub new { return bless {},shift; } sub hello { print "hello"; }
While this doesn't:hello
output:#!/usr/bin/perl use warnings; use strict; sub new { print "haha"; return; } my $a = new Foo; $a->hello; package Foo; sub new { return bless {},shift; } sub hello { print "hello"; }
Bareword "Foo" not allowed while "strict subs" in use at test.pl line +10. Execution of test.pl aborted due to compilation errors.
|
|---|