473,406 Members | 2,847 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,406 software developers and data experts.

[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.MyProduct;

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 2539
Because you can multiple different namespaces?

"cody" <de********@gmx.de> wrote in message
news:ul*************@tk2msftngp13.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.MyProduct;

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*************@tk2msftngp13.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.MyProduct;

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
understanding 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
understanding 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
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...
2
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...
15
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...
4
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...
21
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...
47
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...
34
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...
10
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...
25
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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,...
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
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.