2

I looked at Get containing path of lua file, and I can see that:

print(debug.getinfo(1).source)

... results with e.g.:

@/Users/e/test.lua

Apparently, as a path, this is a string - but what is the "at sign"/"at character" @ there for; what does it mean?

It was otherwise quite difficult finding anything useful related to this, by doing an internet search for Lua "at sign" (even with quotation marks)

sdbbs
  • 4,270
  • 5
  • 32
  • 87

1 Answers1

4

It means that the function was defined in a file.

From the Lua 5.4 Reference Manual: 4.7 The Debug Interface

The fields of lua_Debug have the following meaning:

source: the source of the chunk that created the function. If source starts with a '@', it means that the function was defined in a file where the file name follows the '@'. If source starts with a '=', the remainder of its contents describes the source in a user-dependent manner. Otherwise, the function was defined in a string where source is that string.

The Lua manual lists other uses of @. For example warn("@off") can be used to turn off the emission of warnings.

Piglet
  • 27,501
  • 3
  • 20
  • 43
  • Many thanks for the answer @Piglet - feels good to know where to finally find this information! – sdbbs Apr 17 '21 at 09:59