.fflush() in stdio.d

Jonathan M Davis newsgroup.d at jmdavisprog.com
Mon Aug 26 09:14:23 UTC 2019


On Sunday, August 25, 2019 11:59:08 PM MDT berni via Digitalmars-d-learn 
wrote:
> Out of curiosity: Browsing the source of stdio.d I found that
> flush() is implemented by calling fflush from some C++ library.
> What I don't understand: Why is the call to fflush preceded by a
> dot?

The dot makes it so that it's specifically referencing a module-level symbol
(be it in that module or an imported module) instead of a local or member
symbol.

https://dlang.org/spec/module.html#module_scope_operators

In this particular case, it doesn't look like the dot is necessary, because
File doesn't have an fflush member, but there are a number of cases where it
has a member that's the same as a C function that it wraps, in which case
the dot would be necessary to reference the C function instead of the member
function. So, it wouldn't surprise me if whoever wrote that code was just
putting a dot in front of C function calls in general.

- Jonathan M Davis





More information about the Digitalmars-d-learn mailing list