Thread overview | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
October 25, 2022 [Issue 2753] Cannot declare pointer to function returning ref | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=2753 Bolpat <qs.il.paperinik@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |qs.il.paperinik@gmail.com --- Comment #10 from Bolpat <qs.il.paperinik@gmail.com> --- @Walter: It is “broken” in the sense that the grammar should(!) be able to express a type without requiring type aliases. I’d suggest minimal changes to the Type grammar to allow for it. TL;DR: The semantics is obvious, I hope. Let’s allow the following: ```d ref (int function()) f1(); (ref int function()) f2(); void g1(ref (int function()) fp); void g2((ref int function()) fp); void hImpl(DG : ref int delegate())(DG dg) { } alias h = fImpl!(ref int delegate() @safe); ``` ――― End of TL;DR ――― Note that `f1` and `g1` are equivalent to: ```d ref int function() f1(); void g1(ref int function() fp); ``` In the grammar, I use `?` to signify optional occurrence. ```diff Type: TypeCtors? BasicType TypeSuffixes? + ref TypeCtors? BasicType CallableSuffix TypeSuffixes? BasicType: FundamentalType . QualifiedIdentifier QualifiedIdentifier Typeof Typeof . QualifiedIdentifier − TypeCtor ( Type ) + TypeCtor? ( Type ) Vector TraitsExpression MixinType TypeSuffix: * [ ] [ AssignExpression ] [ AssignExpression .. AssignExpression ] [ Type ] + CallableSuffix + + CallableSuffix: delegate Parameters MemberFunctionAttributes? function Parameters FunctionAttributes? ``` (This grammar diff does not address the special casing for `alias` that is currently in place and superseded by this. As far as I can tell, it’ll be still good and should not be changed.) It is worth considering to deprecate the syntax without disambiguating parentheses, akin to comparison and bit-wise operators and `() => { }`. The deprecation only applies to cases where a non-aliased function pointer or delegate type is used on a `ref` parameter or as the return type of a `ref` returning function. -- |
October 25, 2022 [Issue 2753] Cannot declare pointer to function returning ref | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=2753 Dlang Bot <dlang-bot@dlang.rocks> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull --- Comment #11 from Dlang Bot <dlang-bot@dlang.rocks> --- @Bolpat created dlang/dlang.org pull request #3446 "Fix Issue 2753" fixing this issue: - Fix Issue 2753 https://github.com/dlang/dlang.org/pull/3446 -- |
December 17, 2022 [Issue 2753] Cannot declare pointer to function returning ref | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=2753 Iain Buclaw <ibuclaw@gdcproject.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P2 |P4 -- |
May 17, 2023 [Issue 2753] Cannot declare pointer to function returning ref | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=2753 --- Comment #12 from Dlang Bot <dlang-bot@dlang.rocks> --- @ntrel updated dlang/dmd pull request #15243 "[new syntax] Support `function` `ref` Type Parameters for function pointer types" fixing this issue: - Fix Issue 2753 - Cannot declare pointer to function returning ref. https://github.com/dlang/dmd/pull/15243 -- |
May 17, 2023 [Issue 2753] Cannot declare pointer to function returning ref | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=2753 --- Comment #13 from Dlang Bot <dlang-bot@dlang.rocks> --- @Bolpat updated dlang/dmd pull request #15245 "Fix Issue 2753" fixing this issue: - Fix issue 2753 - add good case tests https://github.com/dlang/dmd/pull/15245 -- |
May 26, 2023 [Issue 2753] Cannot declare pointer to function returning ref | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=2753 --- Comment #14 from Dlang Bot <dlang-bot@dlang.rocks> --- @Bolpat created dlang/dlang.org pull request #3616 "Primary Type Syntax" fixing this issue: - Fix Issue 2753 https://github.com/dlang/dlang.org/pull/3616 -- |
May 26, 2023 [Issue 2753] Cannot declare pointer to function returning ref | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=2753 --- Comment #15 from Dlang Bot <dlang-bot@dlang.rocks> --- @Bolpat created dlang/dmd pull request #15269 "Primary Type Syntax" fixing this issue: - Fix issue 2753 - add good case tests https://github.com/dlang/dmd/pull/15269 -- |
November 08, 2023 [Issue 2753] Cannot declare pointer to function returning ref | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=2753 --- Comment #16 from Nick Treleaven <nick@geany.org> --- *** Issue 21521 has been marked as a duplicate of this issue. *** -- |
October 19 [Issue 2753] Cannot declare pointer to function returning ref | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=2753 Nick Treleaven <nick@geany.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nick@geany.org --- Comment #17 from Nick Treleaven <nick@geany.org> --- (In reply to anonymous4 from comment #2) > int goo(int function() ref foo); //return byref function Allowing that would seem to be a simple fix to the problem, except now it would be confusing with the `return ref` attribute. The latter didn't exist when you wrote that though. -- |
October 19 [Issue 2753] Cannot declare pointer to function returning ref | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=2753 --- Comment #18 from Stewart Gordon <smjg@iname.com> --- (In reply to Nick Treleaven from comment #17) > (In reply to anonymous4 from comment #2) >> int goo(int function() ref foo); //return byref function > > Allowing that would seem to be a simple fix to the problem, except now it would be confusing with the `return ref` attribute. The latter didn't exist when you wrote that though. I stand by what I said before. It makes no sense to me to have the notation for "reference to an integer" split in two like this. To me, that notation reads as declaring foo as a byref parameter, not as a parameter of function-with-byref-return type. I think most people would agree. Hence my earlier proposal: > int foo(int function() ref goo); // ref parameter > int goo(int ref function() foo); // ref return in parameter Here, the 'ref' would be exactly the same as '*' for pointers and '[]' for arrays in terms of how it is placed. That 'ref' is a keyword rather than a symbol shouldn't have to make any difference to this. -- |
Copyright © 1999-2021 by the D Language Foundation