PeachQ
MIT-licensed open source q. An early preview you can try in the browser.
This document contains the standard conventions that we follow and recommend that others follow. It is very heavily based on the K: Remarks on Style - No Stinking Loops updated to be based on q. It covers indentation, comments, declarations, statements, white space, naming conventions, programming practices and includes examples. (source)
Where possible q idiomatic syntax should be used, take advantage of the power q provides. i.e. Use adverbs where possible rather than loops. Use inline functions with implicit parameters, Use q's right-to-left evaluation to use as few brackets as possible but not at the cost of clarity. e.g.
Typically for libraries intended for use by others:
Overall Naming Rules
| Scope | Entity | Convention | Example |
|---|---|---|---|
| Contexts | Short camelcase starting with lowercase. | .ts | |
| Global | Variables | Begin with uppercase letter. | Counter |
| Constants | All upper-case | REUTERSID | |
| Functions | Begin with lowercase letter. verbNoun pairs | executeTrade | |
| Local | Functions | Begin with lowercase letter. verbNoun pairs | executeTrade |
| Variables | Begin with lowercase letter. Very limited scope use single letters otherwise longer nouns. | a, b, messageCount, corruptMessages |
Comments should follow the qDoc format where possible, allowing generation of html documentation.
e.g.
Never elide semicolons projections, always make explicitly clear it is a projection. e.g.
f[;2;] / rather than f[;2]
MIT-licensed open source q. An early preview you can try in the browser.