Global <const> syntax?

,

Is there a syntax to create a global <const>? I'm getting board of writing:

local pd <const> = playdate
local gfx <const> = pd.graphics

I know, and am currently, just not making then <const>, e.g.:

pd = playdate
gfx = pd.graphics
ui = pd.ui
sprite = gfx.sprite
file = pd.file

<const> is specifically an attribute of local variable declarations, its purpose being to prevent assignments to a variable after initialization (reference).

As boring as repeating the local declarations in every file may get, it does more of the heavy lifting here, as subsequent access to those local variables is meant to be faster than looking up a global like playdate.graphics (or gfx from the second snippet) each time.

1 Like

Ok. My trying to be clever isn't actually so clever after all.

1 Like