[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Roadmap for Ravi - 2017
- From: Sean Conner <sean@...>
- Date: Sat, 14 Jan 2017 18:33:38 -0500
It was thus said that the Great Dibyendu Majumdar once stated:
> Hi Sean,
>
> >> 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-)