authorgravatar for kappaloris@gmail.comLoris Cro <kappaloris@gmail.com> 2025-02-23 17:57:28+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-02-26 14:41:33-05:00
loge3da2852f421ec2e7d568373b3f29030818e1d77
treec285d4607bdbb58cc6b6cef9445b7b1880bd702a
parent466fa311b18e7178921f6e37d6b0244b3c707b5d

`@deprecated`: add suggested changes to langref entry


1 files changed, 10 insertions(+), 11 deletions(-)

doc/langref.html.in+10-11
......@@ -4746,19 +4746,18 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
47464746 <pre>{#syntax#}@deprecated() void{#endsyntax#}</pre>
47474747 <p>
47484748 Used to mark a given code path as deprecated. It evaluates to the same value
4749 passed in as argument, or the {#syntax#}void{#endsyntax#} value when given none.
4749 passed in as argument, or the void value when given none.
47504750 </p>
47514751 <p>
4752 As an example, in Zig 0.14.0 {#syntax#}std.time.sleep{#endsyntax#} was
4753 deprecated and the sleep function was moved to {#syntax#}std.Thread.sleep{#endsyntax#}.
4754 This is how this deprecation could have been expressed:
4755
4756 {#syntax_block|zig|lib/std/time.zig#}
4757pub const sleep = @deprecated(std.Thread.sleep); // moved
4758 {#end_syntax_block#}
4752 As an example, a library that wishes to move or rename a declaration, while
4753 deprecating usage of the old name can use {#syntax#}@deprecated{#endsyntax#} like so:
47594754 </p>
4755 {#syntax_block|zig|root.zig#}
4756pub const fooToBar = @deprecated(bar.fromFoo); // moved
4757 {#end_syntax_block#}
4758
47604759 <p>
4761 By default it is a <b>compile error</b> to depend on deprecated code in
4760 By default it is a <b>compile error</b> to reference deprecated code in
47624761 a module defined by the root package, while it is not in modules defined
47634762 by dependencies. This behavior can be overridden for the entire dependency
47644763 tree by passing {#syntax#}-fallow-deprecated{#endsyntax#} or
......@@ -4772,9 +4771,9 @@ pub const sleep = @deprecated(std.Thread.sleep); // moved
47724771 </p>
47734772
47744773 <p>
4775 {#syntax#}@deprecated{#endsyntax#} can also be used without argument:
4776 {#code|test_deprecated_builtin.zig#}
4774 Using {#syntax#}@deprecated{#endsyntax#} without an argument can be useful inside of blocks:
47774775 </p>
4776 {#code|test_deprecated_builtin.zig#}
47784777
47794778 {#header_close#}
47804779