@@ -406,12 +406,12 @@ $(H2 $(LNAME2 visibility_attributes, Visibility Attribute))
406
406
407
407
$(GRAMMAR
408
408
$(GNAME VisibilityAttribute):
409
- $(D private )
409
+ $(D export )
410
410
$(D package)
411
411
$(D package) $(D $(LPAREN)) $(GLINK2 type, QualifiedIdentifier) $(D $(RPAREN))
412
+ $(D private)
412
413
$(D protected)
413
414
$(D public)
414
- $(D export)
415
415
)
416
416
417
417
$(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).)
421
421
$(P Visibility participates in $(DDSUBLINK spec/module, name_lookup, symbol name lookup).
422
422
)
423
423
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))
429
446
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
431
448
from code in other modules that are in the same package.
432
449
If no identifier is provided, this applies to the innermost package only,
433
450
or defaults to $(D private) if a module is not nested in a package.
434
451
)
435
452
436
453
$(P $(D package) may have an optional parameter in the form of a dot-separated identifier
437
454
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
439
456
will be visible in the specified package and all of its descendants.
440
457
)
441
458
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
+
442
469
$(P $(D protected) only applies inside classes (and templates as they can be mixed in)
443
470
and means that a symbol can only be seen by members of the same module,
444
471
or by a derived class.
@@ -448,31 +475,12 @@ attributes in documents predating $(LINK2 http://wiki.dlang.org/DIP22, DIP22).)
448
475
$(D protected) module members are illegal.
449
476
)
450
477
478
+ $(H3 $(LNAME2 public, $(D public) Attribute))
479
+
451
480
$(P $(D public) means that any code within the executable can see the member.
452
481
It is the default visibility attribute.
453
482
)
454
483
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
-
476
484
477
485
$(H2 $(LNAME2 mutability, Mutability Attributes))
478
486
0 commit comments