www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - UFCS requires explicit this

reply d coder <dlang.coder gmail.com> writes:
Greetings

Consider the following code ...

class Foo { // 1
  void foo() { // 2
    bar(); // 3
    this.bar(); // 4
  } // 5
} // 6
void bar(Foo f) { // 7
  import std.stdio; // 8
  writeln("This bar"); // 9
} // 10
void main() { // 11
  Foo test = new Foo; // 12
  test.foo(); // 13
} // 14

DMD is fine with line 4 because of UCFS. But it gives an error for line 3
because it does not get this pointer to bind as argument.

I want to know if it is a DMD bug or whether line 3 would be compilable at
some point in future.

Regards
- Puneet
May 04 2013
parent reply Timon Gehr <timon.gehr gmx.ch> writes:
This is to be expected.
May 04 2013
parent reply d coder <dlang.coder gmail.com> writes:
Timon, you mean such support is planned, or is the current behavior the
expected behavior.

Regards
- Puneet



On Sat, May 4, 2013 at 4:57 PM, Timon Gehr <timon.gehr gmx.ch> wrote:

 This is to be expected.
May 04 2013
parent Timon Gehr <timon.gehr gmx.ch> writes:
On 05/04/2013 01:57 PM, d coder wrote:
 Timon, you mean such support is planned, or is the current behavior the
 expected behavior.
 ...
The current behaviour is expected. UFCS is a rewrite rule from a.b(args...) to b(a,args...).
May 04 2013