Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7835217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:33:21+00:00 2026-06-02T13:33:21+00:00

Lua 5.1.4 For example: bar = {} bar.name = ‘test’ bar[‘123.com’] = function(self) print(self.name)

  • 0

Lua 5.1.4

For example:

bar = {}
bar.name = 'test'
bar['123.com'] = function(self) print(self.name) end

I can’t call the method like below:

bar:['123.com']()
stdin:1: '<name>' expected near '['

Althought below works:

bar['123.com'](bar)

But I this is somehow ugly. Is there a syntax sugar for this situation?

Or if it really cannot do it, will Lua team add this syntax in future?

Or they did this intentionally?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T13:33:22+00:00Added an answer on June 2, 2026 at 1:33 pm

    Nobody knows what the Lua maintainers will add in future versions (they’re pretty close-mouthed), but my guess would be that it’s unlikely they’ll add it without at least being asked—and I’ve never seen a request for such a thing on the Lua mailing list…

    My intuition, though, is that this functionality seems obscure: how often do people really want to call methods with “weird” names like that? Given that, and that the “workaround” really isn’t bad at all, it’s unclear whether it’s worth adding complexity to the implementation to support such a feature (unless it’s completely trivial).

    If you want to try asking, you should post about it to the Lua mailing list, which is where most such discussion takes place: lua-l@lists.lua.org

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For example: local a = Lua local u = Луа print(a:len(), u:len()) output: 3
Lua has a really nice no-parenthesis call syntax that coupled with function closures allow
It seems that in Lua, I can either pass vararg on to another function,
How can I write a Unicode symbol in lua. For example I have to
I'm trying to use lua for windows - SciTE Simply example such as Print(hello)
I'm wondering how to use functions from another script in Lua. For example, say
#1 Lua: local test = Test(); #2 C: //creating lua's test luaL_newmetatable(L, someTable); lua_userdata
Does Lua provide a function to make the first character in a word uppercase
I am embedding Lua into a C/C++ application. Is there any way to call
How can I retrieve a password from user input in Lua in a way

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.