Make dur a property?

Nick Sabalausky SeeWebsiteToContactMe at semitwist.com
Wed Jan 23 14:46:05 PST 2013


On Wed, 23 Jan 2013 21:29:14 +0100
Andrej Mitrovic <andrej.mitrovich at gmail.com> wrote:

> On 1/23/13, Adam D. Ruppe <destructionator at gmail.com> wrote:
> > On Wednesday, 23 January 2013 at 17:13:05 UTC, Timon Gehr wrote:
> > Amen! -property MUST die. @property should fix the real problems
> > with properties, not leave that broken while adding new problems.
> 
> About @property problems, I've recently ran into this:
> ModuleInfo.unitTest is defined as
> 
> @property void function() unitTest() nothrow pure;
> 
> And if I use it:
> 
>     foreach (m; ModuleInfo)
>     {
>         if (m is null)
>             continue;
> 
>         if (auto fp = m.unitTest)
>         {
>             fp();           // calls it
>             m.unitTest();   // doesn't call it
>             m.unitTest()(); // calls it
>         }
>     }
> 
> This is regardless of the -property switch. I would expect the second
> call to work. Anyone know if this is filed already?

Don't know if it's filed, but yea: Optional empty-parens and
the practice of conflating properties with functions is riddled with
corner-cases. We can either try to patch over these corner cases
with increasingly detailed new rules, as Andrei is proposing, or we
can just accept "the writing on the wall" (if you'll pardon my 80's-ism)
that properties != functions.



More information about the Digitalmars-d mailing list