ziglang/ziglang.org
14
29
Fork
You've already forked ziglang.org
31

[doc] 0.16.0/master: Update information about Parameter Reference Optimization #614

Open
opened 2026年05月12日 11:18:39 +02:00 by flip-rossi · 0 comments

Documentation#Pass-by-value Parameters states:

Structs, unions, and arrays can sometimes be more efficiently passed as a reference, since a copy could be arbitrarily expensive depending on the size. When these types are passed as parameters, Zig may choose to copy and pass by value, or pass by reference, whichever way Zig decides will be faster. This is made possible, in part, by the fact that parameters are immutable.

The closing comment on GitHub issue #5973 however, implies this is no longer the case. I couldn't find the actual behavior or change notes about this, and would be nice to know what is possible for the code to actually do.

The docs should be updated to reflect these changes in the language, as it can lead to people: 1. copying huge structs into functions thinking the compiler will optimize it away; and 2. being needlessly scared of aliasing where it can't happen anymore :P

[Documentation#Pass-by-value Parameters](https://ziglang.org/documentation/0.16.0/#toc-Pass-by-value-Parameters) states: > Structs, unions, and arrays can sometimes be more efficiently passed as a reference, since a copy could be arbitrarily expensive depending on the size. When these types are passed as parameters, Zig may choose to copy and pass by value, or pass by reference, whichever way Zig decides will be faster. This is made possible, in part, by the fact that parameters are immutable. [The closing comment on GitHub issue #5973](https://github.com/ziglang/zig/issues/5973#issuecomment-4334852241) however, implies this is no longer the case. I couldn't find the actual behavior or change notes about this, and would be nice to know what is possible for the code to actually do. The docs should be updated to reflect these changes in the language, as it can lead to people: 1. copying huge structs into functions thinking the compiler will optimize it away; and 2. being needlessly scared of aliasing where it can't happen anymore :P
Sign in to join this conversation.
No Branch/Tag specified
main
release-0.16.0
apraga/french
homersimpsons/fix/mobile-responsiveness
MarkLagodych/patch-1
Zirunis/patch-1
zmitchell/zmitchell/build-graph-docs
generalmimon/fix-unit-testing-examples
generalmimon/fix-code-snippet-in-0.15.1-relnotes
TheConnorJohnson/main
meeting-minutes
enkvadrat/update-curl-example
No results found.
Labels
Clear labels
bounty
https://ziglang.org/news/announcing-donor-bounties
bug
Observed behavior contradicts documented or intended behavior.
contributor-friendly
This issue is limited in scope and/or knowledge of project internals.
downstream
An issue with a third-party project that uses this project.
enhancement
Solving this issue will likely involve adding new logic or components to the codebase.
infra
An issue related to project infrastructure, e.g. continuous integration.
optimization
A task to improve performance and/or resource usage.
question
No questions on the issue tracker; use a community space instead.
regression
Something that used to work in a previous version stopped working
upstream
An issue with a third-party project that this project uses.
use case
Describes a real use case that is difficult or impossible, but does not propose a solution.
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ziglang/ziglang.org#614
Reference in a new issue
ziglang/ziglang.org
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?