Property discussion wrap-up
Timon Gehr
timon.gehr at gmx.ch
Wed Jan 30 11:24:40 PST 2013
On 01/30/2013 07:49 PM, TommiT wrote:
> On Wednesday, 30 January 2013 at 18:06:47 UTC, Timon Gehr wrote:
>> This is subject to 4 exceptions:
>>
>> auto foo() { ... }
>>
>> 1. &foo // get function pointer or delegate
>> 2. alias x = foo; // alias to function (same for alias params)
>> 3. typeof(foo) // type of function
>> 4. foo() // function called
>
> I'd count only 1. and 3. as exceptions to the rule.
They are all exceptions that an implementation does need to consider.
> I don't see how is
> 4. is an exception - it's just a regular function call without omitting
> the parens.
It is an exception because foo means call foo, and foo() means call foo,
and not call foo and then the result of foo.
> I'm not sure if it's possible to create an alias to an
> expression like:
>
> alias x = foo;
>
> ...but if it's possible,
That is mostly a compiler implementation detail. (Create a hidden enum
symbol vs store the value in the alias directly.) Expressions may bind
to template alias params.
I think rule 2. should probably be replaced/extended by:
2. Foo!foo // direct template argument
template Bar(int x) { ... }
int foo(){ ... }
mixin Bar!foo; // error
(Alternatively DMD may be declared to be in error here.)
> then I think it's fine to allow it. It will
> work as if x were the expression it aliases,
> ...
That is how it works for identifiers.
More information about the Digitalmars-d
mailing list