Proposal: simplified `out' and `ref' parameters

7 views
Skip to first unread message

Anton Shepelev

unread,
Aug 31, 2022, 6:06:02 AMAug 31
to
Hello, all

As one coming to C# from Pascal and practising proce-
dural programming, I am regularly annoyed by the in-
ability to pass properties as `out' and `ref' parame-
ters. Don't you think that C# should be smarter and
higher-level than that, and treat those parameters as
an algernative method of assignment. That way, whenev-
er a.b = c; works, proc(out a.b) shall work too, as
long as the `out' parameter has the type of `c'. Will
it not make `out' and `ref' parameters conceptually
simpler and more useful?

--
() ascii ribbon campaign - against html e-mail
/\ http://preview.tinyurl.com/qcy6mjc [archived]

Arne Vajhøj

unread,
Aug 31, 2022, 5:50:03 PMAug 31
to
On 8/31/2022 6:05 AM, Anton Shepelev wrote:
> As one coming to C# from Pascal and practising proce-
> dural programming, I am regularly annoyed by the in-
> ability to pass properties as `out' and `ref' parame-
> ters. Don't you think that C# should be smarter and
> higher-level than that, and treat those parameters as
> an algernative method of assignment. That way, whenev-
> er a.b = c; works, proc(out a.b) shall work too, as
> long as the `out' parameter has the type of `c'. Will
> it not make `out' and `ref' parameters conceptually
> simpler and more useful?

I am not sure that it will be that much used (out and
ref are generally pretty rare).

But on the other hand I don't think there is any
doubt about the programmers intention matching
the proposed functionality.

You can try suggest it to the C# team (I doubt
they read here).

Arne


Anton Shepelev

unread,
Oct 13, 2022, 8:10:05 AMOct 13
to
Arne Vajhoj to Anton Shepelev:

> > As one coming to C# from Pascal and practising pro-
> > cedural programming, I am regularly annoyed by the
> > inability to pass properties as `out' and `ref' pa-
> > rameters. Don't you think that C# should be smarter
> > and higher-level than that, and treat those parame-
> > ters as an algernative method of assignment. That
> > way, whenever a.b = c; works, proc(out a.b) shall
> > work too, as long as the `out' parameter has the
> > type of `c'. Will it not make `out' and `ref' param-
> > eters conceptually simpler and more useful?
>
> I am not sure that it will be that much used (out and
> ref are generally pretty rare).

As one who prefer procedural programming to OOP, I use
them quite frequently, and C# being a multiparadigm lan-
guage, my proposal seems not against the grain of it.

> But on the other hand I don't think there is any doubt
> about the programmers intention matching the proposed
> functionality.

Glad to hear that. Yes, I think my proposal will make
out and ref parameters conceptually simpler: a more gen-
eral way to return data from methods.

> You can try suggest it to the C# team (I doubt they
> read here).

Sure, but I wanted some informal feedback from you in-
cluding thee. Thank you.

--
() ascii ribbon campaign - against html e-mail
/\ www.asciiribbon.org - against proprietary attachments
Reply all
Reply to author
Forward
0 new messages