Hacker News new | past | comments | ask | show | jobs | submit login

> As an aside, is there some reason that using the same identifier with different cases is desirable?

It is mostly for conventions, however different cases are generally used to represent different things. For example, in Python:

- ALL_CAPS: global variables

- PascalCase: for classes, and now that Python has typing annotations, types

- snake_case: everything else, from variables to function/method names

(This is not a rule, Python allows anything anywhere, so it is just a convention).

So for example, in Nim you couldn't have PERSON (global variable) and Person (class), however you could still have Person (class definition) and person (class instance). Of course, applying the code style from a language to another language is silly, however it is just to illustrate the value of case sensitive identifiers (if you think that my example is more or less valuable than having the flexibility of using a external library the way you want this is your choice).

BTW, nowadays I am studying Golang and I found it annoying that you capitalization is meaningful in Go, so person() is a private function however Person() is public. It is generally not bad, however sometimes I want to create a global private constant and can't simple call it MY_CONSTANT since this would make it public.




You get used to the capitalisation. In python the _ prefix threw me off at first as well, but it just kind of grows on you I suppose.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: