digitalmars.D.learn - what is the mean that call function start with a dot.
- lili (3/3) Sep 21 2019 Hi:
- Paul Backus (3/6) Sep 21 2019 It means that `fn` is looked up in the module's top-level scope.
- Jonathan M Davis (15/23) Sep 21 2019 which includes any top-level imports, so the symbol in question isn't
Hi: yesterday I saw some d code, where is an .fn() call syntax, what is it mean.
Sep 21 2019
On Sunday, 22 September 2019 at 04:15:53 UTC, lili wrote:Hi: yesterday I saw some d code, where is an .fn() call syntax, what is it mean.It means that `fn` is looked up in the module's top-level scope. Source: https://dlang.org/spec/expression.html#identifier
Sep 21 2019
On Saturday, September 21, 2019 10:32:08 PM MDT Paul Backus via Digitalmars- d-learn wrote:On Sunday, 22 September 2019 at 04:15:53 UTC, lili wrote:which includes any top-level imports, so the symbol in question isn't necessarily within the module. The key thing is that when a symbol is preceded by a dot, no local or member symbols are taken into account. It makes it so that if you have a local or member symbol which has the same name as a top-level symbol, you're able to directly reference the top-level symbol without providing the entire module path. So, for instance, if a socket class had a close method, that close method could call the C function, close, with .close, whereas otherwise, it would have to do something like core.sys.posix.unistd.close (at least on POSIX systems) to call the C function, since if it called close without any kind of path, it would end up recursively calling the close member function, because the module-level function is shadowed by the member function. - Jonathan M DavisHi: yesterday I saw some d code, where is an .fn() call syntax, what is it mean.It means that `fn` is looked up in the module's top-level scope. Source: https://dlang.org/spec/expression.html#identifier
Sep 21 2019