Identifiable Identifiers

Standardised conventions for identifier naming

Last updated 2025 July 28

When programming in Desmos, I use a set of naming conventions for identifiers. This helps massively when managing increasingly large projects with many identifiers to keep track of.

It’s by no means a perfect convention, but I’ve found it to be quite intuitive and efficient. I document it in depth here for anyone who wishes to use it.1

Overview

Identifiers take the form bsubscriptb_\text{subscript}, where bb is the base. This is hugely preferable to single-letter naming, which quickly drains available variable names and results in clashes.

Global variables use an uppercase base, while functions, actions and their parameters use a lowercase base.

V=0Gtick=0f(x)=x2v(tnext)=Gticktnextegin{align*} V &= 0 quad&quad G_ ext{tick} &= 0 \ f(x) &= x^2 quad&quad v(t_ ext{next}) &= G_ ext{tick} o t_ ext{next} end{align*}

The subscript is all in lowercase. Short subscripts are preferable to reduce clutter, but increasing length may become necessary to avoid naming collisions.

Words are not separated with any separator due to Desmos limitations. This clearly has issues, but it’s preferable to camelCase and still holds up fine with some extra effort in naming appropriately.

Glastgamesave=1csave()=GlastgamesaveGtickegin{align*} G_ ext{lastgamesave} &= 1 \ c_ ext{save}() &= G_ ext{lastgamesave} o G_ ext{tick} end{align*}

Variables

lettersemanticsdescriptionnotesinstance
C\textcolor{#f07d1c}{C}colourStores an RGB colour.Cblue\textcolor{#f07d1c}{C}_\text{blue}
G\textcolor{#f07d1c}{G}globalA global variable, whether dynamic or static.Glive\textcolor{#f07d1c}{G}_\text{live}
T\textcolor{#f07d1c}{T}tickA tick variable for timing events.Tspawn\textcolor{#f07d1c}{T}_\text{spawn}
W\textcolor{#f07d1c}{W}worldA globally accessible store of game data, often objects.Wobjects\textcolor{#f07d1c}{W}_\text{objects}
R\textcolor{#f07d1c}{R}renderThe output of a rendering function.Rbox\textcolor{#f07d1c}{R}_\text{box}

Functions / Actions

lettersemanticsdescriptionnotesinstance
a\textcolor{#f07d1c}{a}actionA general action.Specifically those intended to be manually triggered.areset(...)\textcolor{#f07d1c}{a}_\text{reset}(...)
c\textcolor{#f07d1c}{c}control / coreA core action for running the game.ctick(...)\textcolor{#f07d1c}{c}_\text{tick}(...)
d\textcolor{#f07d1c}{d}drawA function for rendering polygons to the viewport.drect(...)\textcolor{#f07d1c}{d}_\text{rect}(...)
f\textcolor{#f07d1c}{f}functionA pure function2 that performs computations instead of modifying state.Intended for commonly used utility functions.flsrange(...)\textcolor{#f07d1c}{f}_\text{lsrange}(...)
n\textcolor{#f07d1c}{n}newAn action for creating new objects (internally).nenemy(...)\textcolor{#f07d1c}{n}_\text{enemy}(...)
v\textcolor{#f07d1c}{v}moveAn action for moving something forward in time – either literally or by processing its frame updates.vv for velocity in physics, literally changing position.vplayer(...)\textcolor{#f07d1c}{v}_\text{player}(...)
w\textcolor{#f07d1c}{w}handleAbstraction upon v()v(), usually for branching between different v()v() depending on conditional.wcollision(...)\textcolor{#f07d1c}{w}_\text{collision}(...)

Parameters

lettersemanticsdescriptionnotesinstance
i\textcolor{#f07d1c}{i}indexA number that can be used to index a list.iZ,i1i \in \mathbb{Z}, i \geq 1
l\textcolor{#f07d1c}{l}listA list of objects.The type of the objects can be described in the subscript, like lpl_p for a list of points.flsrange(l,speriod,soffset)f_\text{lsrange}(\textcolor{#f07d1c}{l}, s_\text{period}, s_\text{offset})
n\textcolor{#f07d1c}{n}numberAn integer.nZ,n0n \in \mathbb{Z}, n \geq 0
p\textcolor{#f07d1c}{p}pointAn (x,y)(x, y) pair of values.Must be a point, cannot be a list (will be accessed via p.xp.x or p.yp.y).flclamp(p)f_\text{lclamp}(\textcolor{#f07d1c}{p})
s\textcolor{#f07d1c}{s}parameterA generic parameter.
t\textcolor{#f07d1c}{t}timeProgression along a spectrum.0t10 \leq t \leq 1flerp(sstart,sstop,t)f_\text{lerp}(s_\text{start}, s_\text{stop}, \textcolor{#f07d1c}{t})

  1. Including me!!
  2. In the functional programming sense!