lua-users home
lua-l archive

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

Hello Community,

I'm pleased to announce luajls 0.7 [1], the noticeable changes are:
- an effort to clear and simplify the APIs,
- new features such as Async/Await for Promise [2], Abstract Syntax Tree module to parse and generate Lua code [3], - new concepts such as *Exception* to group the error message and its associated stack [4], *Codec* to encode/decode a string [5].

The async/await pattern allows asynchronous/non-blocking functions to be written in a traditional synchronous/blocking style, see example below [6].

All feedbacks are welcome.

Thank you and have a good day,

[6] Async/Await example:
local event = require('jls.lang.event')
local Promise = require('jls.lang.Promise')

local function incrementLater(n, millis) -- asynchronous function that return a promise that will resolve after a timeout
  return Promise:new(function(resolve)
    event:setTimeout(resolve, millis or 0, n + 1)

Promise.async(function(await) -- async itself is asynchronous and return a promise   local n = await(incrementLater(1, 1000)) -- await will block then return 2 after 1 second
  print(await(incrementLater(n, 1000))) -- prints 3 after another second