On Tuesday, 26 November 2019 at 03:06:52 UTC, Omar wrote:
the page here https://dlang.org/spec/function.html
suggests you can implement a function in a different file
...
mentioned the endeavour of no-bodied-functions as a way of presenting a black-box type of interface.

oh, that's what you were asking.

Consider:

  $ cat interface/references.d
  module references;

  string greeting();

  $ cat implementation/references.d
  module references;

  string greeting() {
      return "Hello, Dave";
  }

  $ cat main.d
  import references;

  void main() {
      import std.stdio: writeln;
      writeln(greeting);
  }

And trying to build it:

  $ dmd -c implementation/references.d
  $ dmd -Iinterface -c main.d
  $ dmd main.o references.o
  $ ./main
  Hello, Dave

Reply via email to