473,608 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[Proposal] Short namespace syntax

Why do we always need braces around namespaces?

It frightens me that even a simply class looks so much nested and
complicated due to this verbose namespace syntax. It also unnecessarily
increases the indentation level of *every* file. The funny thing is that I
cannot imagine one single situatation where it *could* be useful to have
more than one namespace per file.

Why not simply allow (additional to the existing syntax) simply this:

namespace MyCompany.MyPro duct;

This short namespace declaration, if present, must appear only once per file
and above all other statements in the file. If someone sees this syntax he
can be sure that this file has only one namespace.
Nov 16 '05 #1
8 2550
Because you can multiple different namespaces?

"cody" <de********@gmx .de> wrote in message
news:ul******** *****@tk2msftng p13.phx.gbl...
Why do we always need braces around namespaces?

It frightens me that even a simply class looks so much nested and
complicated due to this verbose namespace syntax. It also unnecessarily
increases the indentation level of *every* file. The funny thing is that I
cannot imagine one single situatation where it *could* be useful to have
more than one namespace per file.

Why not simply allow (additional to the existing syntax) simply this:

namespace MyCompany.MyPro duct;

This short namespace declaration, if present, must appear only once per
file and above all other statements in the file. If someone sees this
syntax he can be sure that this file has only one namespace.

Nov 16 '05 #2
then, you provide meaning to the file itself. The language has no
understanding of the notion of a file. All of the files in the project can
be viewed, from the standpoint of the compiler, as belonging to a single
long stream of text.

This is nearly always easier from the standpoint of the tools. The language
is more elegant and it is easier to refactor the code.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"cody" <de********@gmx .de> wrote in message
news:ul******** *****@tk2msftng p13.phx.gbl...
Why do we always need braces around namespaces?

It frightens me that even a simply class looks so much nested and
complicated due to this verbose namespace syntax. It also unnecessarily
increases the indentation level of *every* file. The funny thing is that I
cannot imagine one single situatation where it *could* be useful to have
more than one namespace per file.

Why not simply allow (additional to the existing syntax) simply this:

namespace MyCompany.MyPro duct;

This short namespace declaration, if present, must appear only once per
file and above all other statements in the file. If someone sees this
syntax he can be sure that this file has only one namespace.

Nov 16 '05 #3
>It also unnecessarily
increases the indentation level of *every* file.


You're not forced to indent the class inside the namespace block you
know.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 16 '05 #4
then, you provide meaning to the file itself. The language has no
understandin g of the notion of a file.


The using and extern alias directives are already scoped to a single
file.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 16 '05 #5
> >It also unnecessarily
increases the indentation level of *every* file.


You're not forced to indent the class inside the namespace block you
know.


I do not have to but it looks even more stupid if I have braces and do not
ident them, at the end they are still there.
However if I do not ident them visual studio does it for me.
Nov 16 '05 #6
> Because you can multiple different namespaces?

Did you really read my post? That was exactly my point: I know no case where
someone would actually need more than one namespace per file. In the rare
case someone actually does, the old namespace syntax can still be used.
Nov 16 '05 #7
>>then, you provide meaning to the file itself. The language has no
understandi ng of the notion of a file.


The using and extern alias directives are already scoped to a single
file.


Which defeats Nick's point as a whole :)
Since using directives and namespaces declarations are very related they
should also be treated the same.
Nov 16 '05 #8
> then, you provide meaning to the file itself. The language has no
understanding of the notion of a file. All of the files in the project
can be viewed, from the standpoint of the compiler, as belonging to a
single long stream of text.


If multiple *.cs files are concatenated it won't compile because the using
directives can only appear a the beginning of the file.
Also the preprocessor first has to remove #define statements which are also
scoped per file and resolve #if #else clauses.

So even if there should be a problem with backward compatibility that the
new syntax allows namespaces declarations without braces, the preprocessor
could insert the braces automatically
Nov 16 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
978
by: Tim Hochberg | last post by:
As soon as one of these syntax discussions go on long enough, I start to think that, whatever the problem ,it should be solved by thunks (search python dev if you need to know what a thunk is) or something thunk-like. It's a personal weakness, I suppose. In that vein, here's my entry into the Great Decorator Debate 2004. def NAME as EXPRESSION: BLOCK BLOCK is executed in a separate namespace *before* EXPRESSION is
2
1700
by: Guido van Rossum | last post by:
Robert and Python-dev, I've read the J2 proposal up and down several times, pondered all the issues, and slept on it for a night, and I still don't like it enough to accept it. The only reason to accept it would be to pacify the supporters of the proposal, and that just isn't a good enough reason in language design. However, it got pretty darn close! I'm impressed with how the community managed to pull together and face the enormous...
15
2581
by: Ralf W. Grosse-Kunstleve | last post by:
****************************************************************************** This posting is also available in HTML format: http://cci.lbl.gov/~rwgk/python/adopt_init_args_2005_07_02.html ****************************************************************************** Hi fellow Python coders, I often find myself writing:: class grouping:
4
2722
by: wkaras | last post by:
I would like to propose the following changes to the C++ Standard, the goal of which are to provide an improved ability to specify the constraints on type parameters to templates. Let me say from the start that my knowledge of compiler implementation is very limited. Therefore, my suggestions may have to be rejected because they are difficult or impossible to implement. The proposal is based on the concept of "type similarity". Type...
21
1516
by: Michael Hoffman | last post by:
What would people think about adding sys to __builtins__ so that "import sys" is no longer necessary? This is something I must add to every script I write that's not a one-liner since they have this idiom at the bottom: if __name__ == "__main__": sys.exit(main(sys.argv)) Additionally, the necessity of "import sys" makes some one-liners a little more unwieldy than they should be--it is surely the module I am
47
3337
by: Pierre Barbier de Reuille | last post by:
Please, note that I am entirely open for every points on this proposal (which I do not dare yet to call PEP). Abstract ======== This proposal suggests to add symbols into Python. Symbols are objects whose representation within the code is more important than their actual value. Two symbols needs only to be
34
1852
by: glomde | last post by:
i I would like to extend python so that you could create hiercical tree structures (XML, HTML etc) easier and that resulting code would be more readable than how you write today with packages like elementtree and xist. I dont want to replace the packages but the packages could be used with the new operators and the resulting IMHO is much more readable. The syntax i would like is something like the below:
10
3289
by: =?iso-8859-2?B?SmFuIFJpbmdvuQ==?= | last post by:
Hello everybody, this is my first post to a newsgroup at all. I would like to get some feedback on one proposal I am thinking about: --- begin of proposal --- Proposal to add signed/unsigned modifier to class declarations to next revision of C++ programming language
25
3017
by: Lennart Benschop | last post by:
Python has had the Decimal data type for some time now. The Decimal data type is ideal for financial calculations. Using this data type would be more intuitive to computer novices than float as its rounding behaviour matches more closely what humans expect. More to the point: 0.1 and 0.01 are exact in Decimal and not exact in float. Unfortunately it is not very easy to access the Decimal data type. To obtain the decimal number 12.34 one...
0
8063
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8003
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8478
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8152
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8341
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
3962
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2474
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1598
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1331
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.