lua-users home
lua-l archive

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




Dibyendu Majumdar <mobile@majumdar.org.uk> 于2019年5月22日周三 上午7:47写道:
The latest commits show the syntax <toclose> being adopted instead of *toclose.

Aesthetically I find the new syntax to be nicer, but this still has
the problem that the previous syntax had; which is that the symbol '<'
has meaning in expressions therefore using this symbol (like the *
symbol) may restrict the ability to use extensions inside expressions.
Of course extensions will always be restricted to local declarations
in which case it doesn't matter.

Regards
Dibyendu

I have a new idea about the syntax of <toclose>, what about this?

local function get_content(filename)
    local f: toclose = assert(io.open(filename, "rb"))
    return f:read "*a"
end

just use :, it's just like the type annotation, and it opens a way to makes Lua support (optional) type declarations.

--
regards,
Xavier Wang.