www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Proposition

reply imr1984 <imr1984_member pathlink.com> writes:
I have a proposition.

Some programmers (including me) dont want to organize their programs into
classes/structs because they are worried that by doing so would mean that every
global function would have a hidden extra parameter, which in a large program
could pose a potential slow down (wether this is true or not is besides the
point). 

So it means that their programs become big messes of global variables /
functions, and everything can be accessed from anywhere without any
qualification.

So I propose that D be included with a keyword that would make any global in a
specific module require qualification before it can be used. 

For example if I had a global variable in module.d called x, any file in my
program could access x just by doing:

int test = x;

-and it would be very unclear where x comes from. With this proposed keyword the
programmer would be forced to type:

int test = module.x;

Which is lot clearer. I know that D allows you to qualify the name already, but
more often than not people wont bother, and this proposed keyword ("qualify"?)
would help maintain readability in large programs where OOP is not used.
Apr 15 2005
parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"imr1984" <imr1984_member pathlink.com> wrote in message 
news:d3om7g$lsf$1 digitaldaemon.com...
 With this proposed keyword the
 programmer would be forced to type:

 int test = module.x;

 Which is lot clearer. I know that D allows you to qualify the name 
 already, but
 more often than not people wont bother, and this proposed keyword 
 ("qualify"?)
 would help maintain readability in large programs where OOP is not used.

Ahh, yet another use for explicit namespaces.. ;)
Apr 15 2005
parent reply imr1984 <imr1984_member pathlink.com> writes:
Are namespaces planned for D?

In article <d3p7p3$163t$1 digitaldaemon.com>, Jarrett Billingsley says...
"imr1984" <imr1984_member pathlink.com> wrote in message 
news:d3om7g$lsf$1 digitaldaemon.com...
 With this proposed keyword the
 programmer would be forced to type:

 int test = module.x;

 Which is lot clearer. I know that D allows you to qualify the name 
 already, but
 more often than not people wont bother, and this proposed keyword 
 ("qualify"?)
 would help maintain readability in large programs where OOP is not used.

Ahh, yet another use for explicit namespaces.. ;)

Apr 15 2005
parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"imr1984" <imr1984_member pathlink.com> wrote in message 
news:d3pj10$1ep0$1 digitaldaemon.com...
 Are namespaces planned for D?

I hope so. They were something I suggested a few weeks ago. Walter never replied, but that usually doesn't mean much. In any case, explicit namespaces could solve your problem and mine..
Apr 16 2005