On Monday, 29 March 2021 at 02:12:57 UTC, Brad wrote:
a custom implementation for writeln rather than use the one in stdout module (package?) that would mean any other functions from that package I would want to leverage I would need to include by name.

You can still import std.stdio and use other functions with just the one overridden.

D handles name lookups by just ... well, looking up lol. It starts in the current scope, then checks the next one up until the module, then starts looking at imported modules for the name.

If there's two with the same name, it prefers the most local one, but you can override that by using the full name:

import std.stdio;
void writeln() {}

writeln(); // since you have a local name, it uses that first
getc(); // no local name, so it checks the imported modules
std.stdio.writeln(); // specifically uses the one from the module

Reply via email to