On Wed, Jul 4, 2018 at 9:04 AM, Russell Haley wrote:
I'm just now reading about Lua in Garry's Mod and it seems to me they've "polluted" the global space with this thing called an API. I don't know anything about the details yet but it looks pretty handy.
Yes, all game scripting systems expose their API as hundreds of global objects/functions/variables.
It looks pretty handy indeed, but there is a small problem here.
For example, in Garry's Mod there are global names (belonging to API) such as
Vector, Sound, Player, Path, Entity, Color, Angle
which could be occasionally shadowed out by local variables with the same name.
This is quite popular mistake, because it is hard to keep in mind whole huge API. When reading a script, it may be not obvious where variable "Vector" comes from: is it API function or local variable?
"$" prefix would be useful here: it would act as a bright indicator "from API"/"not from API", so most of api-object-was-shadowed-out mistakes would disappear.