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

add ref-return-scope table #3607

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 2 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
33 changes: 30 additions & 3 deletions spec/function.dd
Original file line number Diff line number Diff line change
Expand Up @@ -1905,9 +1905,32 @@ $(H3 $(LNAME2 ref-return-scope-parameters, Ref Return Scope Parameters))
When a parameter is passed by `ref` and has both the `return` and `scope` storage classes,
it gets $(LINK2 #return-scope-parameters, `return scope`) semantics if and only if the `return` and `scope`
keywords appear adjacent to each other, in that order.
Specifying a `return ref` and `scope` parameter enables returning a reference to a scope pointer.
In all other cases, the parameter has $(LINK2 #return-ref-parameters, `return ref`) semantics
and regular $(LINK2 #scope-parameters, `scope`) semantics.)
This behavior is summarized as follows:)

$(TABLE2 Combinations of `ref` $(COMMA) `return` and `scope`,
$(THEAD Order, Interpretation)
$(TROW `ref`, $(REFP))
$(TROW `return`, `return`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return is not an interpretation

Suggested change
$(TROW `return`, `return`)
$(TROW `return`, $(RETURN_SCOPE))

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It depends on the context. See mtype.buildScopeRef

$(TROW `scope`, $(SCOPE))
$(TROW `return ref`, $(RETURN_REF))
$(TROW `ref return`, $(RETURN_REF))
$(TROW `return scope`, $(RETURN_SCOPE))
$(TROW `scope return`, $(RETURN_SCOPE))
$(TROW `ref scope`, $(REFP) and $(SCOPE))
$(TROW `scope ref`, $(REFP) and $(SCOPE))
$(TROW `ref return scope`, $(REFP) and $(RETURN_SCOPE))
$(TROW `return scope ref`, $(REFP) and $(RETURN_SCOPE))
$(TROW `ref scope return`, $(RETURN_REF) and $(SCOPE))
$(TROW `return ref scope`, $(RETURN_REF) and $(SCOPE))
$(TROW `scope return ref`, $(RETURN_REF) and $(SCOPE))
$(TROW `scope ref return`, $(RETURN_REF) and $(SCOPE))
RazvanN7 marked this conversation as resolved.
Show resolved Hide resolved
)

$(BEST_PRACTICE do not use `ref return` and `scope return`.)

$(P Specifying a `return ref` and `scope` parameter enables returning a reference to a scope pointer.
In all other cases, the parameter has $(RETURN_REF) semantics
and regular $(SCOPE) semantics.)

---
U xerxes( ref return scope V v) // (1) ref and return scope
Expand Down Expand Up @@ -4230,3 +4253,7 @@ Macros:
TITLE=Functions
ASSIGNEXPRESSION=$(GLINK2 expression, AssignExpression)
CHECK=✔
REFP=$(LINK2 #ref-params, `ref`)
RETURN_REF=$(LINK2 #return-ref-parameters, `return ref`)
SCOPE=$(LINK2 #scope-parameters, `scope`)
RETURN_SCOPE=$(LINK2 #return-scope-parameters, `return scope`)
PetarKirov marked this conversation as resolved.
Show resolved Hide resolved