Documentation page https://dlang.org/spec/function.html#scope-parameters about scope
function parameters says simply that a scoped parameter "can't escape that function's scope". This concept can be very tricky with some non-trivial algebra of struct's members and pointers, so I think it's better to provide a general algorithm to state if an expression/statement involving one or more scope
function parameters is valid or not.
Thread overview |
---|
April 15, 2022 List of all permitted operations on scope function parameters. | ||||
---|---|---|---|---|
| ||||
April 15, 2022 Re: List of all permitted operations on scope function parameters. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Loara | On Friday, 15 April 2022 at 21:57:28 UTC, Loara wrote: >Documentation page https://dlang.org/spec/function.html#scope-parameters about scope and return are both my nightmare. But when I come across these elsewhere, it's scary. Especially in function parameters! @SDB79 |
April 16, 2022 Re: List of all permitted operations on scope function parameters. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Salih Dincer | On Friday, 15 April 2022 at 23:17:26 UTC, Salih Dincer wrote: >On Friday, 15 April 2022 at 21:57:28 UTC, Loara wrote: >Documentation page https://dlang.org/spec/function.html#scope-parameters about scope and return are both my nightmare. But when I come across these elsewhere, it's scary. Especially in function parameters! @SDB79 Exactly, but i think that if correctly defined |
April 17, 2022 Re: List of all permitted operations on scope function parameters. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Salih Dincer | On Friday, 15 April 2022 at 23:17:26 UTC, Salih Dincer wrote: >On Friday, 15 April 2022 at 21:57:28 UTC, Loara wrote: >Documentation page https://dlang.org/spec/function.html#scope-parameters about scope and return are both my nightmare. But when I come across these elsewhere, it's scary. Especially in function parameters! @SDB79 https://github.com/Loara/Rethink_scope_in_D/blob/main/README.md |
April 17, 2022 Re: List of all permitted operations on scope function parameters. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Loara | On Sunday, 17 April 2022 at 08:57:40 UTC, Loara wrote: >On Friday, 15 April 2022 at 23:17:26 UTC, Salih Dincer wrote: >On Friday, 15 April 2022 at 21:57:28 UTC, Loara wrote: >Documentation page https://dlang.org/spec/function.html#scope-parameters about scope and return are both my nightmare. But when I come across these elsewhere, it's scary. Especially in function parameters! @SDB79 https://github.com/Loara/Rethink_scope_in_D/blob/main/README.md The first example you give is actually well rejected but only in
> /tmp/temp_7F010929C2D0.d:8:11: Error: scope variable it's not mentioned in the specs for |
April 17, 2022 Re: List of all permitted operations on scope function parameters. | ||||
---|---|---|---|---|
| ||||
Posted in reply to user1234 | On Sunday, 17 April 2022 at 12:35:25 UTC, user1234 wrote: >On Sunday, 17 April 2022 at 08:57:40 UTC, Loara wrote: >On Friday, 15 April 2022 at 23:17:26 UTC, Salih Dincer wrote: >On Friday, 15 April 2022 at 21:57:28 UTC, Loara wrote: >Documentation page https://dlang.org/spec/function.html#scope-parameters about scope and return are both my nightmare. But when I come across these elsewhere, it's scary. Especially in function parameters! @SDB79 https://github.com/Loara/Rethink_scope_in_D/blob/main/README.md The first example you give is actually well rejected but only in
> /tmp/temp_7F010929C2D0.d:8:11: Error: scope variable it's not mentioned in the specs for It's not a compilation error, it's an incomplete documentation issue since if we follows only the official documentation this should compile, and it'll compile if we remove the innermost block (as explained in the next example). Making scope operation not transitive let it a cumbersome tool that force programmers to use a lot of casts. Notice also that the preceding code will compile if we translate it to
because the The real question at this point is: we want to make I don't see at this moment any clear objective behind the In the next articles I'll explain better the idea of a scoped block as a way to statically control which indirections escapes and which not. |