lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 03-Oct-22 19:39, Francisco Olarte wrote:
On Mon, 3 Oct 2022 at 19:24, bil til <biltil52@gmail.com> wrote:
if I call f.abc() where .abc does not exist,
Sorry, but a basic question from a Lua beginner, not in "Lua tricks
state" yet, sorry... . (and I do not really see how you can call this
solution approach "simple" :) ).
I assume, you do NOT have any access to f, e. g. f would be a module
loaded from some external source?

Not the OP, but it may be the opposite problem ( he wants to pass the
table to someone which calls arbitrary methods, possibly with a
somehow more complicated logic for function generation ).

(as if you would have the table f defined INSIDE this lua file, then
it should be very straight forward just to add an additional function
f.abc(...)?)

If it were just the file, he could just call print("abc",...) ;->  I
would assume it is a proof of concept of a more complex thing ( given
the global variable usage, among other things ).

Francisco Olarte.

It will be a small cog in the redesign of my old Medusa compiler
https://www.erix.it/medusa.html

The call f.abc() happens in the book 'source'; 'abc' will be an arbitrary string for a CSS class selector, defined by the book's author.

Thanks to all who pointed out my beginner's mistake!
It makes me feel many, many years younger ;-)

As I said, I had noy touched Lua for some time (sigh).

--
  Enrico