Bug or not? "Functions cannot return a function"

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Wed Nov 16 19:10:33 PST 2016


On Thursday, November 17, 2016 02:53:50 Meta via Digitalmars-d wrote:
> On Thursday, 17 November 2016 at 02:47:50 UTC, Stefan Koch wrote:
> > I think you are doing a parenthesis-less call.
>
> I swear optional parens is going to drive me insane. Why
> @property wasn't just fixed instead of the current horribly
> broken and unintuitive situation, I'll never know.

The number one reason? Because folks hated the extra parens with UFCS. e.g.
with optional parens, you get stuff like

auto r = range.map!foo.filter!(a => a < 5);

whereas without them you have to do

auto r = range.map!foo().filter!(a => a < 5)();

With UFCS and ranges, you end up with a lot of situations where you use
parens for the template argument, and a lot of folks thought that then
having to put the empty parens on the end was just ugly. If we didn't have
UFCS, then optional parens used with non-property functions would be a lot
less appealing. But once UFCS was added, any chance of having strong
property enforcement for @property pretty much died. As it stands, we really
should fix @property for callables so that you can use @property to have a
property function which returns a callable and is called without the extra
parens, or we should arguably just get rid of @property.

Regardless, optional parens are one of those features that seems really nice
in some situations and gets really annoying in others, and you hit one of
those spots where it's annoying.

- Jonathan M Davis



More information about the Digitalmars-d mailing list