Closed stevan closed 11 years ago
So the issue is this:
package Foo; class Foo {}
Actually creates class Foo::Foo, which may not be what is wanted. The proposed solution is to do:
package Foo; class ::Foo {}
to indicate that we want a top-level class. This maps to how subs behave, so should be easy enough to understand.
Previously this was used as the solution:
package main; class Foo {}
but this breaks down if you want to import functions that your class can use, such as:
package main; use Path::Class qw[ file ]; class Foo {}
which then imported the file function into the main namespace, which is (more often then not) undesirable.
file
Huh, I forgot that sub ::foo { } works. This is just a bug then.
sub ::foo { }
So the issue is this:
Actually creates class Foo::Foo, which may not be what is wanted. The proposed solution is to do:
to indicate that we want a top-level class. This maps to how subs behave, so should be easy enough to understand.
Previously this was used as the solution:
but this breaks down if you want to import functions that your class can use, such as:
which then imported the
file
function into the main namespace, which is (more often then not) undesirable.