[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Roadmap for Ravi - 2017
- From: Dibyendu Majumdar <mobile@...>
- Date: Sun, 15 Jan 2017 00:21:04 +0000
Hi Sean,
On 14 January 2017 at 23:33, Sean Conner <sean@conman.org> wrote:
>> >> 4. More type annotations - such as string, closure and more
>> >> interestingly - a userdata annotation where you can use the __name
>> >> attribute of the metatable to say what type is expected.
>> >
>> > I would avoid trying to overload the __name attribute. This is Ravi, not
>> > Lua, so perhaps come up with your own metamethod [1].
>> >
>>
>> It is not overloading, more making use of this feature. For example,
>> say you have userdata with __name set to 'Foo'. Then the idea is you
>> could declare:
>>
>> function bar ( a : Foo )
>> local b: Foo = a
>> end
>>
>> The compiler can introduce type assertions. This has no performance
>> benefit but it can help make code more robust. The compiler could also
>> determine that any operations on these require metamethod calls.
>
> Okay, that makes mroe sense, but you have your syntax to really work on.
> For instance, I found the following __names in an instance of Lua 5.3:
>
> FILE*
> lpeg-pattern
> org.conman.net:addr
> zlib:zstream
>
> -spc (Well, I loaded a few modules first 8-)
>
>From the parser point of view such names simply won't be allowed in
the declaration so it won't be possible to declare such names. So I
guess that's okay.
Regards