Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spec update for DMD #17068 #3924

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions changelog/2.110.0_pre.dd
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ $(P
)
)

$(LI $(LNAME2 dmd.enable-rvaluerefparam,Enabled -preview=rvaluerefparam after a long testing period.)
$(CHANGELOG_SOURCE_FILE dmd, changelog/dmd.enable-rvaluerefparam.dd)
$(P
You can now supply an rvalue to a ref argument. A temporary will automatically be created for the call.
)
)


)

Expand Down Expand Up @@ -189,6 +196,7 @@ $(D_CONTRIBUTORS
$(D_CONTRIBUTOR Jeremy Baxter)
$(D_CONTRIBUTOR Johan Engelen)
$(D_CONTRIBUTOR Jonathan M Davis)
$(D_CONTRIBUTOR Manu Evans)
$(D_CONTRIBUTOR Martin Kinkelin)
$(D_CONTRIBUTOR Mathias Lang)
$(D_CONTRIBUTOR Nicholas Wilson)
Expand Down
12 changes: 6 additions & 6 deletions spec/function.dd
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,6 @@ $(H2 $(LNAME2 function-return-values, Function Return Values))

$(P Function return values not marked as $(RELATIVE_LINK2 ref-functions, `ref`)
are considered to be rvalues.
This means they cannot be passed by reference to other functions.
)

$(H2 $(LNAME2 pure-functions, Pure Functions))
Expand Down Expand Up @@ -1538,8 +1537,6 @@ $(H3 $(LNAME2 in-params, In Parameters))
When not in use, `in` is equivalent to `const`.)
$(P The parameter is an input to the function. Input parameters behave as if they have
the $(D const scope) storage classes. Input parameters may also be passed by reference by the compiler.)
$(P Unlike $(D ref) parameters$(COMMA) $(D in) parameters can bind to both lvalues and rvalues
(such as literals).)
$(P Types that would trigger a side effect if passed by value (such as types with copy constructor$(COMMA)
postblit$(COMMA) or destructor)$(COMMA) and types which cannot be copied
(e.g. if their copy constructor is marked as $(D @disable)) will always be passed by reference.
Expand All @@ -1553,9 +1550,8 @@ $(H3 $(LNAME2 in-params, In Parameters))

$(H3 $(LNAME2 ref-params, Ref and Out Parameters))

$(P By default, parameters take rvalue arguments.
A `ref` parameter takes an lvalue argument, so changes to its value will operate
on the caller's argument.)
$(P A `ref` parameter receives an lvalue reference to the caller's argument, so changes to its value will operate
on the caller's value.)

$(SPEC_RUNNABLE_EXAMPLE_RUN
---
Expand Down Expand Up @@ -1609,6 +1605,10 @@ $(H3 $(LNAME2 ref-params, Ref and Out Parameters))
apply only to the reference and not the contents.
)

$(P If the caller supplies an rvalue (ie; a literal or enum), a temporary is created on the caller's stack and passed by reference.
The temporary is destroyed by the caller immediately after the function completes.
)

$(H3 $(LNAME2 lazy-params, Lazy Parameters))

$(P An argument to a $(D lazy) parameter is not evaluated before the function is called.
Expand Down
3 changes: 1 addition & 2 deletions spec/glossary.dd
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,7 @@ void test()
$(DD An rvalue is an abstract term referring to a value resulting from an
expression that has no accessible memory address. This lack of address is
only conceptual; the implementation has the liberty to store an rvalue in
addressable memory. Rvalues cannot be changed and cannot be passed to (or
be returned from) functions by reference. An rvalue is the counterpart to
addressable memory. Rvalues cannot be changed. An rvalue is the counterpart to
an lvalue.
)

Expand Down