Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Lua] suggestion - table keys when called should also be strings not variables #1908

Open
RheingoldRiver opened this issue Mar 16, 2019 · 1 comment
Labels
C: Syntax T: enhancement Improvement of existing language features

Comments

@RheingoldRiver
Copy link

I addressed this locally in my theme specification, but currently table keys are default highlighted as strings when you declare them, but then as variables when you call them. I'd suggest defaulting them to highlighting as strings in both contexts, as long as the table key isn't also a function name - so

table.key = table is a variable, key is a string

table.key(value) = table is a variable, key is a function

Screenshot

Code -

function h.argsToDisplayLine(thisLine, processedArgs)
	local lineDisplay = {
		place = thisLine.place and util_esports.placementIcon(thisLine.place),
		placeraw = thisLine.place,
		team = m_team.rightmediumlinked(thisLine.team),
		player = util_text.printIntLink(thisLine.playerlink, thisLine.player),
		points = thisLine.points,
		qual = h.getQual(thisLine),
		forcenewplace = util_args.castAsBool(thisLine.forcenewplace),
		hide = util_args.castAsBool(thisLine.hide),
	}
	local prizes = h.getPrizeDisplay(thisLine, processedArgs)
	util_table.merge(lineDisplay, prizes)
	return lineDisplay
end
@FichteFoll
Copy link
Collaborator

Related: #1842

Lua (and JavaScript for that matter) are special because their mapping data structures have double-duty and serve as both arbitrary key-value storage as well as objects that may have members. Most significantly, they also use the same syntax for both.
Ideally, in alignment with almost all other languages, I'd like to treat direct member access as a variable.member and not as a string. However, in definitions, both are common, although I would argue defining table values manually for the object style usage is more common than the arbitrary key-value because you're more likely to use brackets for indexing there, so I would rather change definitions to something like entity.name.member instead of changing access to string.

cc @Thom1729

@deathaxe deathaxe changed the title Lua suggestion - table keys when called should also be strings not variables [Lua] suggestion - table keys when called should also be strings not variables Aug 31, 2021
@deathaxe deathaxe added T: enhancement Improvement of existing language features C: Syntax labels Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: Syntax T: enhancement Improvement of existing language features
Projects
None yet
Development

No branches or pull requests

3 participants