On Thu, 24 Jan 2013 00:45:02 +0100 Timon Gehr <[email protected]> wrote:
> On 01/23/2013 11:46 PM, Nick Sabalausky wrote: > > On Wed, 23 Jan 2013 21:29:14 +0100 > > Andrej Mitrovic <[email protected]> wrote: > > > >> On 1/23/13, Adam D. Ruppe <[email protected]> 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, > > What are those "new" rules? The rules we already have are sufficient. > Now the compiler needs to implement them properly. > Andrei was just suggesting this: http://forum.dlang.org/post/[email protected] > > 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. > > > > That is not even the point of this discussion. > > a.map!(a=>foo(a,b).map!(a=>2*a)())().days().ago().writeln() > First of all, spacing helps: a.map!( a => foo(a,b).map!(a=>2*a)() )().days().ago().writeln() So does not trying to cram everything into a one-liner: auto descriptiveName = a => foo(a,b).map!(a=>2*a)(); a.map!descriptiveName().days().ago().writeln() And then there's a few () in there, but not only do I fail to see how those hurt anybody, they make perfect sense since "days", "ago" and "writeln" are not data access, they're actions (even if maybe a little too cutely-named in the case of "ago"). (Of course, I'd question the meaningfulness and feasability of passing the "days" type constructor a range instead of a scalar, but I get that that's beside the point ;) )
