lua-users home
lua-l archive

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


> inline comment block is ugly and hard to input, so why not line-based
> type comment?

I have no preference either way, but there two advantages for the
inline comments: (1) they mimic the syntax of typedlua (just remove
comment brackets) and (2) the same parser can be used to handle both.

Paul.

On Sun, Mar 6, 2016 at 11:46 PM, Xavier Wang <weasley.wx@gmail.com> wrote:
> 2016-03-07 15:07 GMT+08:00 Paul K <paul@zerobrane.com>:
>> Hi Dirk,
>>
>>> Typed Lua is an extension of Lua. That is to say, any Lua program
>>> is a valid Typed Lua program, but not vice versa.
>>
>> I discussed [1] briefly couple of extensions I implemented for
>> TypedLua: (1) relaxed parsing [2] to make it more "forgiving" for
>> invalid syntax (as I was planning to use it for validating the code as
>> it's being typed) and (2) accepting TypedLua directives in comments,
>> so one could write:
>>
>> --[[interface Shape
>>   const new:(self, number, number) -> (self)
>> end]]
>> local Shape = require "shape"
>> --[[const]] function Shape:new(x --[[:number]], y --[[:number]])
>> print(self, x, y) return self end
>> local shape --[[:Shape]] = Shape:new(10, 10)
>> print(shape)
>>
>> I've tested integration with ZeroBrane Studio [3], but haven't stayed
>> up-to-date with TypedLua changes.
>>
>> Paul.
>>
>> [1] http://lua-users.org/lists/lua-l/2015-07/msg00579.html
>> [2] https://github.com/pkulchenko/typedlua/commits/relaxed
>> [3] https://github.com/pkulchenko/ZeroBraneStudio/commits/static-analysis-typedlua
>>
>
> inline comment block is ugly and hard to input, so why not line-based
> type comment?
>
> --[[Shape : {
>     new = const (self, number, number) -> (self)
> }]]
> local Shape = require "shape"
>
> function Shape:new(x, y) -- already declared
>     print(self, x, y)
>     return self
> end
>
> -- shape : Shape
> local shape = Shape:new(10, 10)
> print(shape)
>
> --
> regards,
> Xavier Wang.
>