Here is a summary of this thread that answers the original question “When should I write functions that accept symbols instead of strings or booleans?”
If the function actually uses a symbol in a way that it cannot use a string, for example, appearing in a type parameter, then use a symbol. Thanks @Evey
If the function uses the argument to choose one of a handful of behaviors, then either strings or symbols are acceptable. Consider the following when choosing:
- Symbols effectively need to be a single identifiers, with syntactic restrictions. For example,
open("file.txt", "w+")is possible with strings, but not symbols. - There can be performance differences on the order of 10 ns.
- Whether
:argor"arg"is more visually appealing. - Symbols require more knowledge from new users to understand.
Please let me know if I missed any important points.