digitalmars.D - private declaration in module
- novice (7/7) Sep 22 2004 Hello. Can you help me? Newbie question:
- Sjoerd van Leent (15/25) Sep 22 2004 Very simple, all protection attributes are module based (within a class,...
- Bastiaan Veelo (21/31) Sep 22 2004 See protection attributes in
- novice (5/9) Sep 22 2004 Thanks to Sjoerd and Bastiaan!
- Andy Friesen (6/12) Sep 22 2004 Private can be used at the module level too.
- Bastiaan Veelo (5/18) Sep 22 2004 It is not your english, that sentence is misleading. I think "enclosing
- Ben Hinkle (8/26) Sep 22 2004 member,
Hello. Can you help me? Newbie question: how i can hide come functions and other declarations in my D module from import? I want declare one or more public function in module (so other modules can use it), and one or more private (local) functions (for internal usage only, so other modules can't use it directly). Thanks. Alex
Sep 22 2004
novice wrote:Hello. Can you help me? Newbie question: how i can hide come functions and other declarations in my D module from import? I want declare one or more public function in module (so other modules can use it), and one or more private (local) functions (for internal usage only, so other modules can't use it directly). Thanks. AlexVery simple, all protection attributes are module based (within a class, a struct, a template or without) with the exception to protected. package = The module and submodules may access it private = Only the module may access it protected = Only within classes and interfaces, only subclasses may access it public = Every module may access it Also: import = Imported modules are visible to other modules using your module private import = Imported modules are hidden for other modules using your module Regards, Sjoerd
Sep 22 2004
novice wrote:Hello. Can you help me? Newbie question: how i can hide come functions and other declarations in my D module from import? I want declare one or more public function in module (so other modules can use it), and one or more private (local) functions (for internal usage only, so other modules can't use it directly). Thanks. AlexSee protection attributes in http://www.digitalmars.com/d/attribute.html. #module mypackage.mymodule; #package { #private { You're welcome, Bastiaan.
Sep 22 2004
Thanks to Sjoerd and Bastiaan! May be, my question cause is my bad english. At http://www.digitalmars.com/d/attribute.html "private" described as applied to "enclosed class" only, but my program has no classes.Private means that only members of the enclosing class can access the member, or members and functions in the same module as the enclosing class. Private members cannot be overridden. Private module members are equivalent to static declarations in C programs
Sep 22 2004
novice wrote:Thanks to Sjoerd and Bastiaan! May be, my question cause is my bad english. At http://www.digitalmars.com/d/attribute.html "private" described as applied to "enclosed class" only, but my program has no classes.Private can be used at the module level too. module foo; private int helper() { ... } int somethingInteresting() { ... } -- andy
Sep 22 2004
novice wrote:Thanks to Sjoerd and Bastiaan! May be, my question cause is my bad english. At http://www.digitalmars.com/d/attribute.html "private" described as applied to "enclosed class" only, but my program has no classes.It is not your english, that sentence is misleading. I think "enclosing class" should read something like "enclosing class, enclosing template or enclosing module, whatever comes first". Bastiaan.Private means that only members of the enclosing class can access the member, or members and functions in the same module as the enclosing class. Private members cannot be overridden. Private module members are equivalent to static declarations in C programs
Sep 22 2004
"Bastiaan Veelo" <Bastiaan.N.Veelo ntnu.no> wrote in message news:cis370$2jgu$1 digitaldaemon.com...novice wrote:member,Thanks to Sjoerd and Bastiaan! May be, my question cause is my bad english. At http://www.digitalmars.com/d/attribute.html "private" described as applied to "enclosed class" only, but my program has no classes.Private means that only members of the enclosing class can access thePrivateor members and functions in the same module as the enclosing class.staticmembers cannot be overridden. Private module members are equivalent toSome word-smithing wouldn't hurt, but note it does say "Private module members are equivalent to static ..." so it does address what private means for module-level declarations.It is not your english, that sentence is misleading. I think "enclosing class" should read something like "enclosing class, enclosing template or enclosing module, whatever comes first". Bastiaan.declarations in C programs
Sep 22 2004