lua-users home
lua-l archive

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


On Sun, 2 Jun 2019 at 15:14, Xavier Wang <weasley.wx@gmail.com> wrote:
> 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.
>>
> 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.
>

Hi, its been suggested before. Syntactically it is nicer and familiar
as other languages use similar syntax. But ':' is not unambiguous in
expressions as it is used as self operator, so it has the same
drawback as '<>' in that respect.

Regards
Dibyendu