new properties for basic types
via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Jul 15 10:29:25 PDT 2014
On Tuesday, 15 July 2014 at 05:26:57 UTC, Philippe Sigaud via
Digitalmars-d-learn wrote:
> @property allows you to call a function without the parenthesis
> (), to
> imitate a field in a struct or class.
That was the original idea, but today the situation is that for
all argument-less method calls (and UFCS calls) the parentheses
are optional, but for functions with `@property` parentheses
_mustn't_ be used. This was mainly done to avoid an ambiguity
when the function returns something that is itself callable, but
also is useful to keep APIs stable: If you mark a method as
`@property`, you can replace it by a member variable and existing
code will not break (but needs to be recompiled, of course).
More information about the Digitalmars-d-learn
mailing list