Skip to content

Commit e04fa50

Browse files
authored
Merge pull request #3522 from WalterBright/visibility
rearrange Visibility Attributes, add lnames
2 parents 6e6fde7 + 99e7f41 commit e04fa50

File tree

1 file changed

+38
-30
lines changed

1 file changed

+38
-30
lines changed

spec/attribute.dd

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -406,12 +406,12 @@ $(H2 $(LNAME2 visibility_attributes, Visibility Attribute))
406406

407407
$(GRAMMAR
408408
$(GNAME VisibilityAttribute):
409-
$(D private)
409+
$(D export)
410410
$(D package)
411411
$(D package) $(D $(LPAREN)) $(GLINK2 type, QualifiedIdentifier) $(D $(RPAREN))
412+
$(D private)
412413
$(D protected)
413414
$(D public)
414-
$(D export)
415415
)
416416

417417
$(P Visibility is an attribute that is one of $(D private), $(D package),
@@ -421,24 +421,51 @@ attributes in documents predating $(LINK2 http://wiki.dlang.org/DIP22, DIP22).)
421421
$(P Visibility participates in $(DDSUBLINK spec/module, name_lookup, symbol name lookup).
422422
)
423423

424-
$(P Symbols with $(D private) visibility can only be accessed from
425-
within the same module.
426-
Private member functions are implicitly $(DDSUBLINK spec/function, final, `final`)
427-
and cannot be overridden.
428-
)
424+
$(H3 $(LNAME2 export, $(D export) Attribute))
425+
426+
$(P $(D export) means that a symbol can be accessed from outside the executable,
427+
shared library, or DLL. The symbol is said to be exported from where it is defined
428+
in an executable, shared library, or DLL, and imported by another executable, shared library,
429+
or DLL.)
430+
431+
$(P $(D export) applied to the definition of a symbol will export it. $(D export) applied to
432+
a declaration of a symbol will import it.)
433+
434+
---
435+
export int x = 3; // definition, exporting `x`
436+
export int y; // definition, exporting `y`
437+
export extern int z; // declaration, importing `z`
438+
export void f() { } // definition, exporting `f`
439+
export void g(); // declaration, importing `g`
440+
---
441+
442+
$(P In Windows terminology, $(I dllexport) means exporting a symbol from a DLL, and $(I dllimport) means
443+
a DLL or executable is importing a symbol from a DLL.)
444+
445+
$(H3 $(LNAME2 package, $(D package) Attribute))
429446

430-
$(P $(D package) extends private so that package members can be accessed
447+
$(P $(D package) extends $(D private) so that package members can be accessed
431448
from code in other modules that are in the same package.
432449
If no identifier is provided, this applies to the innermost package only,
433450
or defaults to $(D private) if a module is not nested in a package.
434451
)
435452

436453
$(P $(D package) may have an optional parameter in the form of a dot-separated identifier
437454
list which is resolved as the qualified package name. The package must be either the module's
438-
parent package or one of its anscestors. If this optional parameter is present, the symbol
455+
parent package or one of its anscestors. If this parameter is present, the symbol
439456
will be visible in the specified package and all of its descendants.
440457
)
441458

459+
$(H3 $(LNAME2 private, $(D private) Attribute))
460+
461+
$(P Symbols with $(D private) visibility can only be accessed from
462+
within the same module.
463+
Private member functions are implicitly $(DDSUBLINK spec/function, final, `final`)
464+
and cannot be overridden.
465+
)
466+
467+
$(H3 $(LNAME2 protected, $(D protected) Attribute))
468+
442469
$(P $(D protected) only applies inside classes (and templates as they can be mixed in)
443470
and means that a symbol can only be seen by members of the same module,
444471
or by a derived class.
@@ -448,31 +475,12 @@ attributes in documents predating $(LINK2 http://wiki.dlang.org/DIP22, DIP22).)
448475
$(D protected) module members are illegal.
449476
)
450477

478+
$(H3 $(LNAME2 public, $(D public) Attribute))
479+
451480
$(P $(D public) means that any code within the executable can see the member.
452481
It is the default visibility attribute.
453482
)
454483

455-
$(H3 $(LNAME2 export, $(D export) Attribute))
456-
457-
$(P $(D export) means that a symbol can be accessed from outside the executable,
458-
shared library, or DLL. The symbol is said to be exported from where it is defined
459-
in an executable, shared library, or DLL, and imported by another executable, shared library,
460-
or DLL.)
461-
462-
$(P $(D export) applied to the definition of a symbol will export it. $(D export) applied to
463-
a declaration of a symbol will import it.)
464-
465-
---
466-
export int x = 3; // definition, exporting `x`
467-
export int y; // definition, exporting `y`
468-
export extern int z; // declaration, importing `z`
469-
export void f() { } // definition, exporting `f`
470-
export void g(); // declaration, importing `g`
471-
---
472-
473-
$(P In Windows terminology, $(I dllexport) means exporting a symbol from a DLL, and $(I dllimport) means
474-
a DLL or executable is importing a symbol from a DLL.)
475-
476484

477485
$(H2 $(LNAME2 mutability, Mutability Attributes))
478486

0 commit comments

Comments
 (0)