From 095f8978a0d872dfeedfbbce09dd270b203d8beb Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Tue, 16 May 2023 18:17:33 -0700 Subject: [PATCH 1/4] add ref-return-scope table --- spec/function.dd | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/spec/function.dd b/spec/function.dd index 4722baff52..7a8f8028b7 100644 --- a/spec/function.dd +++ b/spec/function.dd @@ -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`) + $(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)) + ) + + $(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 @@ -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`) From d405df28aec24282ca976ae52b93957ece4f5b73 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Thu, 18 May 2023 21:48:24 -0700 Subject: [PATCH 2/4] add article on ref, return, and scope annotations From 46753fc9a987e046035cd842786c8fad5b3490f0 Mon Sep 17 00:00:00 2001 From: Razvan Nitu Date: Fri, 19 May 2023 13:44:51 +0300 Subject: [PATCH 3/4] Update spec/function.dd Co-authored-by: Petar Kirov --- spec/function.dd | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/spec/function.dd b/spec/function.dd index 7a8f8028b7..dabd49e637 100644 --- a/spec/function.dd +++ b/spec/function.dd @@ -1909,21 +1909,16 @@ $(H3 $(LNAME2 ref-return-scope-parameters, Ref Return Scope Parameters)) $(TABLE2 Combinations of `ref` $(COMMA) `return` and `scope`, $(THEAD Order, Interpretation) - $(TROW `ref`, $(REFP)) - $(TROW `return`, `return`) - $(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)) + $(TROW `ref`, $(REFP)) + $(TROW `return`, $(RETURN_SCOPE)) + $(TROW `scope`, $(SCOPE)) + $(TROW `return ref` and `ref return`, $(RETURN_REF)) + $(TROW `return scope` and `scope return`, $(RETURN_SCOPE)) + $(TROW `ref scope` and `scope ref`, $(REFP) and $(SCOPE)) + $(TROW `ref return scope` and `return scope ref`, $(REFP) and $(RETURN_SCOPE)) + $(TROW `ref scope return`$(COMMA) `return ref scope`$(COMMA) + `scope return ref`$(COMMA) and `scope ref return`, $(RETURN_REF) and $(SCOPE)) + ) $(BEST_PRACTICE do not use `ref return` and `scope return`.) From 1fa070504bb8f2a66ac3e27b2525ab5b0ffa9ec9 Mon Sep 17 00:00:00 2001 From: Petar Kirov Date: Fri, 19 May 2023 15:29:17 +0300 Subject: [PATCH 4/4] Update spec/function.dd --- spec/function.dd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/function.dd b/spec/function.dd index dabd49e637..597307122c 100644 --- a/spec/function.dd +++ b/spec/function.dd @@ -4248,7 +4248,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`) + REFP=$(LINK2 #ref-params, $(D ref)) + RETURN_REF=$(LINK2 #return-ref-parameters, $(D return ref)) + SCOPE=$(LINK2 #scope-parameters, $(D scope)) + RETURN_SCOPE=$(LINK2 #return-scope-parameters, $(D return scope))