Special Keywords as Default Arguments

Get introduced to the use of special keywords as default 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 source file including its full path as a string

  • __LINE__: Line number as an int

  • __FUNCTION__: Name of the function as a string

  • __PRETTY_FUNCTION__: Full signature of the function as a string

Although these special keywords can be useful anywhere in code, they work differently when used as default arguments. When they are used in regular code, their values refer to where they appear in the code:

Get hands-on with 1400+ tech skills courses.