@@ -37,12 +37,13 @@ $(GNAME Property):
37
37
$(GLINK UserDefinedAttribute)
38
38
39
39
$(GNAME PropertyIdentifier):
40
- $(RELATIVE_LINK2 property, $(D property) )
41
- $(D safe)
42
- $(D trusted)
43
- $(D system)
40
+ $(RELATIVE_LINK2 property, ` property` )
41
+ $(RELATIVE_LINK2 safe, `@safe` )
42
+ $(RELATIVE_LINK2 safe, `@ trusted` )
43
+ $(RELATIVE_LINK2 safe, `@ system` )
44
44
$(RELATIVE_LINK2 disable, $(D disable))
45
- $(RELATIVE_LINK2 nogc, $(D nogc))
45
+ $(RELATIVE_LINK2 nogc, `nogc`)
46
+ $(RELATIVE_LINK2 disable, `@disable`)
46
47
47
48
$(GNAME DeclarationBlock):
48
49
$(GLINK2 module, DeclDef)
@@ -502,45 +503,13 @@ void main() { foo(); /* error, foo is disabled */ }
502
503
makes the struct not copyable.
503
504
)
504
505
505
- $(H2 $(LNAME2 nogc, $(D @nogc) Attribute))
506
-
507
- $(P $(D @nogc) applies to functions, and means that that function does not
508
- allocate memory on the GC heap, either directly such as with
509
- $(GLINK2 expression, NewExpression) or
510
- indirectly through functions it may call, or through language features
511
- such as array concatenation and dynamic closures.
512
- )
513
-
514
- ---
515
- @nogc void foo(char[] a)
516
- {
517
- auto p = new int; // error, operator new allocates
518
- a ~= 'c'; // error, appending to arrays allocates
519
- bar(); // error, bar() may allocate
520
- }
521
-
522
- void bar() { }
523
- ---
506
+ $(H2 $(LNAME2 safe, $(D @safe), $(D @trusted), and $(D @system) Attribute))
524
507
525
- $(P $(D @nogc) affects the type of the function. An $(D @nogc) function is covariant
526
- with a non-$(D @nogc) function.
527
- )
528
-
529
- ---
530
- void function() fp;
531
- void function() @nogc gp; // pointer to @nogc function
508
+ $(P See $(DDSUBLINK function, function-safety, Function Safety).)
532
509
533
- void foo();
534
- @nogc void bar();
510
+ $(H2 $(LNAME2 nogc, $(D @nogc) Attribute))
535
511
536
- void test()
537
- {
538
- fp = &foo; // ok
539
- fp = &bar; // ok, it's covariant
540
- gp = &foo; // error, not contravariant
541
- gp = &bar; // ok
542
- }
543
- ---
512
+ $(P See $(DDSUBLINK function, nogc-functions, No-GC Functions).)
544
513
545
514
$(H2 $(LNAME2 property, $(D @property) Attribute))
546
515
@@ -643,6 +612,10 @@ $(H2 $(LNAME2 auto, $(D auto) Attribute))
643
612
auto i = 6.8; // declare i as a double
644
613
---
645
614
615
+ $(P For functions, the `auto` attribute means return type inference.
616
+ See $(DDSUBLINK function, auto-functions, Auto Functions).
617
+ )
618
+
646
619
$(H2 $(LNAME2 scope, $(D scope) Attribute))
647
620
648
621
$(P
703
676
704
677
$(H2 $(LNAME2 uda, User Defined Attributes))
705
678
706
- $(P
707
- User Defined Attributes (UDA) are compile time expressions that can be attached
708
- to a declaration. These attributes can then be queried, extracted, and manipulated
709
- at compile time. There is no runtime component to them.
710
- )
711
-
712
- $(P
713
- Grammatically, a UDA is a StorageClass:
714
- )
715
-
716
679
$(GRAMMAR
717
680
$(GNAME UserDefinedAttribute):
718
681
$(D @ $(LPAREN)) $(GLINK2 expression, ArgumentList) $(D $(RPAREN))
@@ -722,7 +685,13 @@ $(GNAME UserDefinedAttribute):
722
685
$(D @) $(GLINK2 template, TemplateInstance) $(D $(LPAREN)) $(GLINK2 expression, ArgumentList)$(OPT) $(D $(RPAREN))
723
686
)
724
687
725
- And looks like:
688
+ $(P
689
+ User Defined Attributes (UDA) are compile-time expressions that can be attached
690
+ to a declaration. These attributes can then be queried, extracted, and manipulated
691
+ at compile time. There is no runtime component to them.
692
+ )
693
+
694
+ A user-defined attribute looks like:
726
695
727
696
---
728
697
@(3) int a;
0 commit comments