Pyli/Naming Conventions

From Jonathan Gardner's Tech Wiki
Jump to: navigation, search

Naming Conventions

I have roughly followed the Scheme method.

  • Generally, everything is lower-case. (Pyli is case-sensitive.)
  • Separate words within a name with a hyphen/minus. camelCase and under_score are discouraged.
  • Global variables (not methods, not classes) are surrounded by *. Ex: *global-setting*
  • Global constants are surrounded by +. Ex: +global-constant+.
  • Types are capitalized.
  • Nouns (instances, classes, etc...) are nouns. Methods are verbs.
  • Use symbols where appropriate. For instance, + means add, - subtract, etc...
  • Use ? to indicate a method that returns True of False. These may be read as "Is X". Ex: iter? (Read: "is iter?")
  • Use ! to indicate dangerous methods, methods that change something, either one or more of the paramters, or a global variable. Ex: next! Note that the def-methods, the methods that define some global, do not need this. Also, methods that manipulate the stack aren't really dangerous, since everything manipulates the stack.
  • Try to keep names short, but don't make them encoded. Use hyphen/minus to separate words. short-names