Search⌘ K

Special Keywords as Default Arguments

Explore how special keywords like __FILE__, __LINE__, and __FUNCTION__ can be used as default arguments in D functions to reflect the call site instead of the definition. Understand how to leverage compile-time literals and tokens to access module names, source files, compiler versions, and timestamps. This lesson helps you write more flexible and informative functions using default and variadic arguments.

We'll cover the following...

Compile-time literals

The following special keywords act like compile-time literals that have values that correspond to where they appear in code:

  • __MODULE__: Name of the module as a string

  • __FILE__: Name of the source file as a string

  • __FILE_FULL_PATH__: Name of the ...