In the new D release why use free functions instead of properties?
monarch_dodra via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Aug 19 09:28:52 PDT 2014
On Monday, 18 August 2014 at 21:17:11 UTC, Jonathan M Davis wrote:
> On Monday, 18 August 2014 at 21:02:09 UTC, Gary Willoughby
> wrote:
>> In the new D release there have been some changes regarding
>> built-in types.
>>
>> http://dlang.org/changelog.html?2.066#array_and_aa_changes
>>
>> I would like to learn why this has been done like this and why
>> it is desired to be free functions rather than properties?
>
> Probably because they never should have been properties in the
> first place. Properties are supposed to emulate variables,
> whereas something like dup is clearly an action. So, it's
> clearly not supposed to be a property. However, because D
> doesn't require parens on a function with no arguments, you can
> still call it without parens. Some of the changes probably also
> help with cleaning up the AA internals, which is sorely needed.
>
> - Jonathan M Davis
Actually, the new free functions *are* properties. All that you
just declared is valid, but we never got around to doing it.
Walter (If I remember correctly) was opposed.
So right now, even if "dup" is a free function, "myArray.dup()"
is still invalid.
:(
More information about the Digitalmars-d-learn
mailing list