Hacker News new | ask | show | jobs
by federico3 3803 days ago
Actually, VariableName != variable_name

You can write ClassesLikePython and variables_like_python in Nim.

Sometimes people end up having dangerously similar variable names in the same scope, e.g. username and user_name, where an incorrect tab-completion might introduce a bug. Nim would require the developer to choose better names.

1 comments

Two identifiers are considered equal if the following algorithm returns true:

    proc sameIdentifier(a, b: string): bool =
      a[0] == b[0] and
        a.replace(re"_|–", "").toLower == b.replace(re"_|–", "").toLower
So, right, looks like it is case sensitive for the first character allowing the same convention from Python. Still, I find it dangerous:

    m_insensitive == min_sensitive
This would be caught by the compiler. If you have m_insensitive declared in current scope you won't be able to define min_sensitive in this scope, the compiler would throw an error.