How do i find a list of the methods Object implements, or maybe just locate the 'write' method?

codephantom me at noyb.com
Wed Nov 8 03:05:22 UTC 2017


On Tuesday, 7 November 2017 at 21:32:26 UTC, Adam D. Ruppe wrote:
> On Tuesday, 7 November 2017 at 21:25:00 UTC, dan wrote:
>> I looked in my distribution's object.d (debian stretch, gdc, in
>
> Did you import std.stdio in the file?
>
> If so, it is calling the std.stdio.write on the object (this is 
> called UFCS, uniform function call syntax, the language allows 
> you to call any free function in scope with obj.foo by 
> rewriting it to foo(obj))
>

it's interesting how the compiler deals with scope.
---------------------------------------------------------------------------
// save this in a file named: write.d

import std.stdio;

void main()
{
     auto o = new Object;

     // One of statements below will prevent this code from 
compiling.
     // Which one do you think it is?

     // btw. If I instead use gdc on debian, then it will
     // compile both statements just fine, and will work as 
expected too.

     o.write;
     write(o);

}

--------------------------------------------------------------------------


More information about the Digitalmars-d-learn mailing list