Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

For example,

function test (a)
    name = nameof(a)
    print(name)
end

test(def) --should print "def"

Are there any lua tricks to implement something similar to the above?


Not that anyone needs to explain why they want to do something; some people get grumpy if they aren't given a real-life example. So:

local function registerTestSuite(suite)
   if (LUnit) then
      LUnit:AddTestSuite(
            HotNReady.."_"..GetVariableName(suite), --HotNReady_PizzaTestSuite
            suite);
   end;
end;
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
958 views
Welcome To Ask or Share your Answers For Others

1 Answer

What you asking for is not possible in pure Lua.

If you really need this, try fiddling with Metalua.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...