July 22 Re: Inlined out arguments declaration | ||||
|---|---|---|---|---|
| ||||
![]() Posted in reply to Juraj | FIXED:
| |||
July 22 Re: Inlined out arguments declaration | ||||
|---|---|---|---|---|
| ||||
user1234 ![]() Posted in reply to Juraj | On Wednesday, 22 July 2026 at 08:25:49 UTC, Juraj wrote: > On Tuesday, 21 July 2026 at 21:20:53 UTC, Richard (Rikki) Andrew Cattermole wrote: >Consider:
You can't prove that this will not dereference null, they are mutually exclusive. And before you say, oh we can disallow logical or expressions! Nope. This is legal D code, not sure it is related to the proposed inline declaration.
> Oh and btw the name of the pattern that C# uses here is called TryGet. And I use this pattern in D daily, the only issue I have is the scope of the out vars. "out vars" is a limited point of view. Imagine a variable declaration as an expression. Everything is more simple. You see, this is something I really worked on; I still believe this would be nice for D. Problem is the way we think default init. Styx is "zeroes", D is "poison you can track". Now about the scope problem. There's no problem. You can test the idea with styx. | |||
July 22 Re: Inlined out arguments declaration | ||||
|---|---|---|---|---|
| ||||
Richard (Rikki) Andrew Cattermole ![]() Posted in reply to Juraj | On 22/07/2026 8:25 PM, Juraj wrote: > This is legal D code, not sure it is related to the proposed /inline declaration/. You have misunderstood the purpose of this syntax, and its implications. The TryGet pattern is unlikely to result in a null value if it returns true. In 2019 C# introduced attributes as part of the compilers static analysis capabilities for nullability specifically to solve this. https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/attributes/nullable-analysis#conditional-postconditions-notnullwhen-maybenullwhen-and-notnullifnotnull ```c# bool TryGetMessage(string key, [NotNullWhen(true)] out string? message) { if (_messageMap.ContainsKey(key)) message = _messageMap[key]; else message = null; return message is not null; } ``` Being legal, and being correct code is two vastly different things. This particular feature being proposed has limited uses outside of the TryGet pattern, so its correctness and program security must be considered and weighted quite heavily compared to other use cases. | |||
July 22 Re: Inlined out arguments declaration | ||||
|---|---|---|---|---|
| ||||
Anton Pastukhov ![]() Posted in reply to Richard (Rikki) Andrew Cattermole | On Wednesday, 22 July 2026 at 09:28:59 UTC, Richard (Rikki) Andrew Cattermole wrote:
> This particular feature being proposed has limited uses outside of the TryGet pattern.
The limited scope of the proposal is intentional. I believe that being a small, low-risk change is the only possible way for it to see the light of day. user1234's idea, as interesting as it is, is unlikely to happen in D.
This is really just a minor syntax sugar/ergonomic improvement. In 2026 D feels old-school and boxy sometimes.
| |||
July 22 Re: Inlined out arguments declaration | ||||
|---|---|---|---|---|
| ||||
Juraj ![]() Posted in reply to Richard (Rikki) Andrew Cattermole | On Wednesday, 22 July 2026 at 09:28:59 UTC, Richard (Rikki) Andrew Cattermole wrote: > You have misunderstood the purpose of this syntax, and its implications. I am saying, you are dismissing this idea on a premise, that something already allowed in the language is problematic. | |||
July 22 Re: Inlined out arguments declaration | ||||
|---|---|---|---|---|
| ||||
Richard (Rikki) Andrew Cattermole ![]() Posted in reply to Anton Pastukhov | On 22/07/2026 10:10 PM, Anton Pastukhov wrote: > On Wednesday, 22 July 2026 at 09:28:59 UTC, Richard (Rikki) Andrew Cattermole wrote: >> This particular feature being proposed has limited uses outside of the TryGet pattern. > > The limited scope of the proposal is intentional. I believe that being a small, low-risk change is the only possible way for it to see the light of day. user1234's idea, as interesting as it is, is unlikely to happen in D. The limited scope of this proposal isn't an issue. Its not far off from what I'd do, if I was to pursue it. See my comment a bit later on in that message: "This particular feature being proposed has limited uses outside of the TryGet pattern, so its correctness and program security must be considered and weighted quite heavily compared to other use cases." > This is really just a minor syntax sugar/ergonomic improvement. In 2026 D feels old-school and boxy sometimes. When Nic introduced variable declaration support to with statements, it broke code. This could be a lot worse depending upon implementation and exact grammar changes. The potential here is for it to infect non-function-argument expressions. | |||
July 22 Re: Inlined out arguments declaration | ||||
|---|---|---|---|---|
| ||||
Nick Treleaven ![]() Posted in reply to Juraj | On Wednesday, 22 July 2026 at 10:19:26 UTC, Juraj wrote: > I am saying, you are dismissing this idea on a premise, that something already allowed in the language is problematic. That is backwards - adding special language support for something that is problematic is by definition problematic. | |||
July 22 Re: Inlined out arguments declaration | ||||
|---|---|---|---|---|
| ||||
Richard (Rikki) Andrew Cattermole ![]() Posted in reply to Juraj | On 22/07/2026 10:19 PM, Juraj wrote:
> On Wednesday, 22 July 2026 at 09:28:59 UTC, Richard (Rikki) Andrew Cattermole wrote:
>
>> You have misunderstood the purpose of this syntax, and its implications.
>
>
> I am saying, you are dismissing this idea on a premise, that something already allowed in the language is problematic.
> So I do not see how that as good argument.
I have not dismissed this based upon what is already existing in the language.
I have dismissed it due to:
1. Interaction with other language features.
2. Reviewing how it is used in C#, which to my knowledge is the only mainstream language & ecosystem example of this.
3. How this would be utilized in PhobosV3, given the C# influence and what classes of bugs we would be recommending people to adopt (which is something both me and Adam want to avoid, if not outright disallow).
4. Introduces new failure cases that require static analysis which I would be the one having to implement AND that static analysis requires attributes to model that people have to use AND there is a much simpler alternative that entirely eliminates that class of bug AND this other feature has been used in multiple mainstream languages & ecosystems without any problems AND this other features doesn't need any kind of static analysis.
Workability of a new language feature is only the starting point, there are other concerns like fallibility, program security and if its modellable that must be considered especially if that feature is a quality of life one.
I've had years to study this particular set of problems, hence my strong opinions.
I do understand why this feature looks attractive.
| |||
July 22 Re: Inlined out arguments declaration | ||||
|---|---|---|---|---|
| ||||
Juraj ![]() Posted in reply to Richard (Rikki) Andrew Cattermole | On Wednesday, 22 July 2026 at 11:19:07 UTC, Richard (Rikki) Andrew Cattermole wrote: >
Fair and good luck >
This is the thing that eludes me, what new failure cases? Just to clarify my position. | |||
September 17 Re: Inlined out arguments declaration | ||||
|---|---|---|---|---|
| ||||
Quirin Schroll ![]() Posted in reply to Juraj | On Tuesday, 21 July 2026 at 17:56:35 UTC, Juraj wrote: > On Tuesday, 21 July 2026 at 17:44:48 UTC, Anton Pastukhov wrote: >Thanks, and I'm glad I'm not the only one bothered with the existing implementation.
should be functionally identical to
...which is perfectly fine D code. There's no behavior change, including the behavior of destructors. Basically having the Please don’t. This is annoying in C#. The declared variables have way too much scope. If the call is verbatim in a scope, put them there. But if they’re on an Example:
Effectively, one can wrap any | |||
Permalink
Reply




