Discussion:
Proposal: simplified `out' and `ref' parameters
(too old to reply)
Anton Shepelev
2022-08-31 10:05:52 UTC
Permalink
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
2022-08-31 21:49:54 UTC
Permalink
Post by Anton Shepelev
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
2022-10-13 12:09:56 UTC
Permalink
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
Loading...