lua-users home
lua-l archive

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


On 18 January 2015 at 14:27, Dibyendu Majumdar <mobile@majumdar.org.uk> wrote:
> Hi,
>
> I am experimenting with the idea of adding optional static typing to
> Lua. The project is very young (only started beginning of the year) so
> the ideas are all in flux. But the overall goal of the project is
> described here:
>
> https://github.com/dibyendumajumdar/ravi
>

Hi,

I am pleased to let you know that I have a working prototype with
following initial features:

1. local variables can be declared 'int' or 'double'.
2. int and double variables are initialized to 0 rather than nil -
this is currently done by emitting additional opcodes.
3. basic arithmetic operations trigger type specific bytecodes if
typed variables are involved
4. values assigned to typed variables are checked - statically unless
the values are results from a function call in which case the there is
an attempt to convert values at runtime.

No support for typed function parameters or return values yet.

Example of code that works:

local function tryme(); local i,j = 5,6; return i,j; end; local i:int,
j:int = tryme(); return i+j

Another example:

local j:double; for i=1,1000000000 do; j = j+1; end; return j

Obviously this is early days so expect bugs.

If anyone wants to try out / break it then please let me have your feedback.

Thanks and Regards

Dibyendu