In the C Programming Language, the #define
directive allows the definition of macros within the source code. These macro definitions allow constant values to be declared for use throughout the code.
Macro definitions are not variables and cannot be changed by the program code like variables. We generally use this syntax when creating constants that represent numbers, strings or expressions. like this
#include <stdio.h>
#define NAME "Jack"
#define AGE 10
int main()
{
printf("%s is over %d years old.\n", NAME, AGE);
return 0;
}
The beauty is that if I have multiple functions in my code I don't need to input the constant variable into every function, and the compiler simply replaces the defined expression with proceeding value.
Now my question is: Is there any equivalent command in Julia programming for this?
for example
density = 1 # somehow a defined variabe.
function bar(g)
t = density +g
end
function foo()
r = dencity + 2
end
main()
g = 10;
foo()
bar(g)
end