Yuescript icon indicating copy to clipboard operation
Yuescript copied to clipboard

[feature request] add support for unicode identifier for variable name

Open pigpigyyy opened this issue 2 years ago • 1 comments

A request from Discord: I wanna be able to do stuff like

💬 'OK OK OK', 'god dammit', 23
📡 = require'satellite'

in no way is this an incredibly important or helpful idea, but i would be happy to use it if it existed.

pigpigyyy avatar Aug 17 '23 03:08 pigpigyyy

Added unicode identifier support for variable names, table indexing, goto labels, macro names and other syntax that can be possible via commit e61cce21ef7def2c2e52dd6cb6a5b540ebcac29d. The code

💬 = print
💬 'OK OK OK', 'god dammit', 23
📡 = require'satellite'

will be compiled to:

local _ud83d_udcac = print
_ud83d_udcac('OK OK OK', 'god dammit', 23)
local _ud83d_udce1 = require('satellite')

And that will leave a problem when you are using unicode names for global variables:

global 🌛 = "moon"
assert _G.🌛 == 🌛, "can not access this global variable with the unicode name"

compiles:

_ud83c_udf1b = "moon"
return assert(_G["🌛"] == _ud83c_udf1b, "can not access this global variable with the unicode name")

pigpigyyy avatar Aug 17 '23 03:08 pigpigyyy