Rant after trying Rust a bit
Tofu Ninja via Digitalmars-d
digitalmars-d at puremagic.com
Fri Jul 24 14:44:40 PDT 2015
On Friday, 24 July 2015 at 21:29:56 UTC, Jonathan M Davis wrote:
> On Friday, 24 July 2015 at 20:46:07 UTC, Tofu Ninja wrote:
>> Is omitting the () not part of ufcs? Or does it have some
>> other name, I can never remember.
>
> No. That's simply omitting the parens from a function call that
> has no arguments. If it has a name, it's just "optional
> parens." Universal Function Call Syntax is the syntax that
> allows you to call a free function as if it were a member
> function, which is why stuff like
>
> auto result = myRange.find(bar);
>
> works. It _does_ mean that you can drop even more parens,
> because the first function argument is now to the left of the
> dot, and the parens are then empty if there was only one
> function argument, but being able to drop the parens has
> nothing to do with UFCS. We could still have UFCS and yet never
> be able to drop parens.
>
> - Jonathan M Davis
Ok I kinda assumed they were both included in the concept of
UFCS, just replace "UFCS" in what I said before with "optional
parens". Basicly I was just saying that I suppose optional parens
do not really make sense on function pointers. Aka if "a" is a
function pointer then auto b = a; should type "b" to a function
pointer as well, which is how it currently works, afik.
But the part that I don't think makes sense for
auto a = {return 4;};
to type "a" to a function pointer. I would expect {return 4;} to
be treated as a function(not a function pointer). With it being
treated as a function, I would expect it to be called with
optional parens and type "a" to an int. I would expect auto
a = &{return 4;};
to type "a" to a function pointer, which makes much more sense to
me. But that's not how function literals work right now. Treating
{return 4;} as a function(not a function pointer) makes a lot
more sense and allows
alias a = {return 4;};
to work as well, which is simply a function declaration.
More information about the Digitalmars-d
mailing list