470,632 Members | 1,825 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,632 developers. It's quick & easy.

Modules and namespaces

Hi,

I'm currently learning C++ and I would like to ask you the difference
between Fortran 95 modules and C++ namespaces. To me they look the
same, except for the scope operator :: in C++, which is a bit more
convenient than F95 rename operator =>, to avoid name clashes. Thank
you,

greetings,

deltaquattro

Feb 14 '07 #1
2 2116
In comp.lang.fortran deltaquattro <de**********@gmail.comwrote:
I'm currently learning C++ and I would like to ask you the difference
between Fortran 95 modules and C++ namespaces. To me they look the
same, except for the scope operator :: in C++, which is a bit more
convenient than F95 rename operator =>, to avoid name clashes. Thank
C++ namespaces are extendible, Fortran modules aren't. Once
you reach the "end module" statement, that's the end of it.
In C++ you can reopen the namespace scope and pile more stuff
into it.

That's one difference. I would be surprised if there aren't many
more. Analogies between Fortran and C++ (or C) are often more
misleading than helpful, so beware.

--
pa at panix dot com
Feb 14 '07 #2
On 14 feb, 16:45, p...@see.signature.invalid (Pierre Asselin) wrote:
In comp.lang.fortran deltaquattro <deltaquat...@gmail.comwrote:
I'm currently learning C++ and I would like to ask you the difference
between Fortran 95 modules and C++ namespaces. To me they look the
same, except for the scope operator :: in C++, which is a bit more
convenient than F95 rename operator =>, to avoid name clashes. Thank

C++ namespaces are extendible, Fortran modules aren't. Once
you reach the "end module" statement, that's the end of it.
In C++ you can reopen the namespace scope and pile more stuff
into it.

That's one difference. I would be surprised if there aren't many
more. Analogies between Fortran and C++ (or C) are often more
misleading than helpful, so beware.
Well, you can join Fortran modules into a new module:

module composite
use module_a
use module_b
...
end module

The new module has all the facilities of the individual ones.

(And interfaces can be defined piecewise as well).

I am not familiar enough with C++'s namespaces to comment on them.

My mental picture of modules is that they do not induce a hierarchy,
but rather import facilities into the current scope and blend them
in seemlessly. I do not think namespaces in C++ work just like that.

Regards,

Arjen
Feb 15 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Andy Jewell | last post: by
1 post views Thread by Dan Williams | last post: by
12 posts views Thread by qwweeeit | last post: by
5 posts views Thread by Ben R. | last post: by
5 posts views Thread by Alex | last post: by
17 posts views Thread by Neil Cerutti | last post: by
173 posts views Thread by Zytan | last post: by
4 posts views Thread by Fabrizio Pollastri | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.