Possible @property compromise
Zach the Mystic
reachBUTMINUSTHISzach at gOOGLYmail.com
Thu Jan 31 14:11:28 PST 2013
On Thursday, 31 January 2013 at 20:52:39 UTC, Steven
Schveighoffer wrote:
>> I'm hoping that the community won't close the books on this
>> issue without even *examining* my proposal, found here:
>>
>> http://forum.dlang.org/thread/kdukid$stg$1@digitalmars.com?page=2#post-yqvrjszzlcpmmuyqyxdz:40forum.dlang.org
>
> I looked at it, it seems extremely similar to C# properties,
> which has been proposed before.
>
> Not that there's anything wrong with it, I'm saying it's a
> duplicate of what has been proposed. If it were to be an
> acceptable solution, I'd be on board (though I don't know why
> we wouldn't use the same notation as C# for familiarity).
>
> Don't hold your breath waiting for Walter to respond though, he
> is notoriously silent unless he completely disagrees with you.
>
> -Steve
Thanks for looking at it.
I only read the C# documentation for properties briefly, but I
didn't find my suggestion to be a duplicate of them. In
particular, can C# properties do anything more than just get and
set? My suggestion allows harnessing the full power of D struct
semantics. Is this not a far more expansive solution than what C#
has?
My opGet is just another opXXX definable for all structs, not
just properties. I had said it was necessary to achieve structs
as properties, but I think I was wrong. It's just the equivalent
of:
int __someRandomFunction() { return _propValue; }
alias __someRandomFunction this;
But it would be syntactically nicer, much like Highlander structs
are syntactically nicer. Therefore, the only language change
absolutely required would be making non-static structs nested in
structs behave like non-static structs nested in functions, which
they arguably should do anyway. Also under the hood, some
important optimizations getting rid of pointers for data-less
structs.
You know, the words "opGet" and "opAssign" (and all the other
opXXX's) are rather ugly, but I guess anyone who has defined them
in the past could come to love them, for their power if not for
their looks.
More information about the Digitalmars-d
mailing list