lua-users home
lua-l archive

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

For Q2, it is not possible  for all tables created with simple t={} syntax. It is possible if you create your tables with a custom constructor.

Em seg., 10 de fev. de 2020 às 17:53, Gavin Holt <> escreveu:

I am having fun chaining string functions to process text in Textadept. This is not for the purists as I have been adding to the standard string library e.g.

    function string.pre(text,prefix)
        -- Prefix each line assuming "\n" for end of line
        return prefix..text:gsub("\n","\n"..prefix)

Adding a few global functions to select and insert text (and define undo_action boundaries), I can then type in the command entry line "macros" e.g.

    selection():pre("--  "):gsub("Python ","Lua "):insert()
Repeatable and undo-able macros and not quite as unreadable as TECO commands :) 

Q1. Is there a limit to the number of chained string methods Lua 5.3 can process?

Q2. Is there any way to use chained methods for tables - in standard Lua 5.3?  
      This syntax appeals to me: 

    t = {"one","two","three"}

Kind Regards Gavin 

Felipe Tavares