473,386 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

difference between namespace and module?

what is the difference between namespace and module?
can anyone help me briefly..
Jul 18 '07 #1
2 1336
numberwhun
3,509 Expert Mod 2GB
what is the difference between namespace and module?
can anyone help me briefly..
Ok, I am going to give you my take on this, but am sure that someone like Miller or KevinADC will be able to add more to this, even possibly links to better explanations.

A module is basically a set of subroutines that are designed to do a specific set of tasks, all with a common goal/topic. You "use" modules in your Perl code and once you do, their functions are available to you.

Now, say you have two modules that end up having two functions with the same name, but do two completely different things. You need to be able to tell them apart. That is where the module, acts like a namespace.

For example, if modules "My::First::Module" and "My::Second::Module" both have a function called "Count()", but you need the version from "My::First::Module", then you would specify that when you called the function, like so:

My::First::Module::Count(options)
{
some code;
}

Ok, that is my take on this topic. Short and sweet. Hopefully, if there is more, and I am sure there is, that someone will enlighten not only you, but me as well.

Regards,

Jeff
Jul 18 '07 #2
KevinADC
4,059 Expert 2GB
just think of the namespaces as boxes or compartments where all the stuff related to a module or your main program are kept. Jeffs explanation seems good enough, it can be extended to include data types too (and some other stuff), so things like:

$foo
@foo
&foo
foo()
*foo

when used in the same package/namespace are kept seperate.
Jul 18 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Blair Hall | last post by:
Can anyone please tell me how to correctly use a built in function when there is a function of the same name in local scope? Here is an example. Suppose the following is in myApply.py: def...
2
by: Fritz Bosch | last post by:
Hi experts Is is possible to import/manipulate a module such that I can supply its __dict__? I want to supply my own dict subclass object to be filled by the import, e.g. a class like: >>>...
8
by: Bo Peng | last post by:
Dear list, I am writing a Python extension module that needs a way to expose pieces of a big C array to python. Currently, I am using NumPy like the following: PyObject* res =...
5
by: Joshua Weir | last post by:
Hi there, I am quite new in terms of server side programming. I understand how asp scripting works and how you put <% %> around your server script. However this is .asp .......what is .aspx? is...
1
by: Solomon Shaffer | last post by:
I have a couple of WebForms that all inherit from a custom base class (which in turn inherits from System.Web.UI.Page). I would like to locate a function in the base class that iterates through the...
4
by: | last post by:
When I add a new module in the project explorer pane, the wizard inserts a Module1 scope, so any variables I will put there can be accessed with a qulification, e.g. dim a as integer will be...
4
by: David A | last post by:
I'm trying to "isolate" some unmanaged calls to DLLs in a separate namespace so I can have all the unmanaged calls to DLL functions in a separate module and then these can be called from any other...
9
by: Fuzzyman | last post by:
Hello, I'm trying to redirect standard out in a single namespace. I can replace sys.stdout with a custom object - but that affects all namespaces. There will be code running simultaneously...
5
by: sophie_newbie | last post by:
OK this might seem like a retarded question, but what is the difference between a library and a module? If I do: import string am I importing a module or a library? And if i do...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.