Namespace or package are same? I use Perl where we only have packages. I know there are other programming languages that also include modules.
What’s the difference?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Namespaceis a general computing term meaning a container for a distinct set of identifiers. The same identifier can appear independently in different namespaces and refer to different objects, and a fully-qualified identifier which unambiguously identifies an object consists of the namespace plus the identifier.Perl implements namespaces using the
packagekeyword.A Perl module is a different thing altogether. It is a piece of Perl code that can be incorporated into any program with the
usekeyword. The filename should end with.pm– for Perl Module – and the code it contains should have apackagestatement using a package name that is equivalent to the file’s name, including its path. For instance, a module written in a file calledMy/Useful/Module.pmshould have apackagestatement likepackage My::Useful::Module.What you may have been thinking of is a class which, again, is a general computing term, this time meaning a type of object-oriented data. Perl uses its packages as class names, and an object-oriented module will have a constructor subroutine – usually called
new– that will return a reference to data that has beenblessedto make it behave in an object-oriented fashion. By no means all Perl modules are object-oriented ones: some can be simple libraries of subroutines.