www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - namespaces

reply imr1984 <imr1984_member pathlink.com> writes:
Who else think that namespaces is a feature lacking in D? I do.

Are there any plans for namespaces in the future?
Apr 16 2005
next sibling parent =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
imr1984 wrote:

 Who else think that namespaces is a feature lacking in D? I do.
 
 Are there any plans for namespaces in the future?

No, there doesn't seem to be any such plans... http://www.digitalmars.com/d/overview.html: (Features To Drop) "Namespaces. An attempt to deal with the problems resulting from linking together independently developed pieces of code that have conflicting names. The idea of modules is simpler and works much better." --anders
Apr 16 2005
prev sibling next sibling parent reply "Joey Peters" <squirrel nidhogg.com> writes:
I would really like such a feature for further grouping my code. Currently 
I'm using templates and mixins, maybe you can use them too if you really 
need a sort of namespace:

# template MyNamespace
# {
#   void Function() { }
# }
# mixin MyNamespace!() Namespace;
# Namespace.Function();

"imr1984" <imr1984_member pathlink.com> schreef in bericht 
news:d3qh64$27t5$1 digitaldaemon.com...
 Who else think that namespaces is a feature lacking in D? I do.

 Are there any plans for namespaces in the future?

 

Apr 16 2005
parent reply pragma <pragma_member pathlink.com> writes:
In article <d3qsfk$2ka6$1 digitaldaemon.com>, Joey Peters says...
I would really like such a feature for further grouping my code. Currently 
I'm using templates and mixins, maybe you can use them too if you really 
need a sort of namespace:

# template MyNamespace
# {
#   void Function() { }
# }
# mixin MyNamespace!() Namespace;
# Namespace.Function();

"imr1984" <imr1984_member pathlink.com> schreef in bericht 
news:d3qh64$27t5$1 digitaldaemon.com...
 Who else think that namespaces is a feature lacking in D? I do.

 Are there any plans for namespaces in the future?

 


You can also get away with this: struct MyNamespace{ static void foo(){ } static int bar; } void main(){ MyNamespace.foo(); MyNamespace.bar(); } - EricAnderton at yahoo
Apr 16 2005
next sibling parent Chris Sauls <ibisbasenji gmail.com> writes:
pragma wrote:
 You can also get away with this:
 
 struct MyNamespace{
 static void foo(){
 }
 static int bar;
 }

Or the (IMHO) slightly "safer" abstract-static-class trick: # public abstract class MyNamespace { static: # void foo () { } # int bar; # } What makes it "safer" is that with a struct some fool could create a variable of type MyNamespace. ...although on further thought, that might actually have its uses for namespace-shortening... but then again that's what 'alias' is for. Too much thought too early in the day. -- Chris Sauls
Apr 16 2005
prev sibling parent reply "Alexander Panek" <alexander.panek brainsware.org> writes:
On Sat, 16 Apr 2005 14:03:46 +0000 (UTC), pragma  
<pragma_member pathlink.com> wrote:

 In article <d3qsfk$2ka6$1 digitaldaemon.com>, Joey Peters says...
 I would really like such a feature for further grouping my code.  
 Currently
 I'm using templates and mixins, maybe you can use them too if you really
 need a sort of namespace:

 # template MyNamespace
 # {
 #   void Function() { }
 # }
 # mixin MyNamespace!() Namespace;
 # Namespace.Function();

 "imr1984" <imr1984_member pathlink.com> schreef in bericht
 news:d3qh64$27t5$1 digitaldaemon.com...
 Who else think that namespaces is a feature lacking in D? I do.

 Are there any plans for namespaces in the future?


You can also get away with this: struct MyNamespace{ static void foo(){ } static int bar; } void main(){ MyNamespace.foo(); MyNamespace.bar(); } - EricAnderton at yahoo

how about just using: /* -- file1.d -- */ module foo; int bar() { return (((2-1+3)*4)/(5^6)); } /* -- file2.d -- */ import foo; void main() { writefln(foo.bar()); } it`s just the same like namespaces, not with { } as limitations but all within a file using "module xy;" is one 'namespace' ... i don`t really get why you need yet-another-"i-reinvent-the-wheel-again"-keyword? :p just my 0,1 cents (i don`t have more), Alex -- huh? did you say something? :o
Apr 17 2005
next sibling parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Alexander Panek" <alexander.panek brainsware.org> wrote in message 
news:opspdtj5r2y2yy8c chello080109082145.3.15.vie.surfer.at...
 how about just using:

 /* -- file1.d -- */
 module foo;

 int bar() { return (((2-1+3)*4)/(5^6)); }

 /* -- file2.d -- */
 import foo;

 void main()
 {
 writefln(foo.bar());
 }

 it`s just the same like namespaces, not with { } as limitations but all 
 within a file using "module xy;" is one 'namespace' ... i don`t really get 
 why you need yet-another-"i-reinvent-the-wheel-again"-keyword? :p

The point is that while we can do this, we can't _force_ the use of qualified names. That's what the OP said anyway.
Apr 18 2005
prev sibling parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Alexander Panek" <alexander.panek brainsware.org> wrote in message 
news:opspdtj5r2y2yy8c chello080109082145.3.15.vie.surfer.at...

Oh wait, that was the thread 3 threads down from this one.. in any case, 
that's that. 
Apr 18 2005
prev sibling next sibling parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"imr1984" <imr1984_member pathlink.com> wrote in message 
news:d3qh64$27t5$1 digitaldaemon.com...
 Who else think that namespaces is a feature lacking in D? I do.

Ooh! Me! Me! ;)
Apr 16 2005
prev sibling parent reply zwang <nehzgnaw gmail.com> writes:
imr1984 wrote:
 Who else think that namespaces is a feature lacking in D? I do.
 
 Are there any plans for namespaces in the future?
 
 

Why do you need namespace while D offers modules?
Apr 16 2005
parent "Unknown W. Brackets" <unknown simplemachines.org> writes:
Please see the "Proposition" thread posted somewhat earlier.

-[Unknown]


 imr1984 wrote:
 
 Who else think that namespaces is a feature lacking in D? I do.

 Are there any plans for namespaces in the future?

Why do you need namespace while D offers modules?

Apr 16 2005