lua-users home
lua-l archive

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


2015-08-01 1:05 GMT+02:00 Christian Thaeter <ct@pipapo.org>:
>
>
> On 2015-07-29 21:23, Dibyendu Majumdar wrote:
>
>> Hi,
>>
>> Ravi allows local declarations and function parameters to have
>> optional type annotations. This obviously makes any code using such
>> annotations incompatible with Lua.
>>
>> It would be nice if Lua had a mode where it ignores any tokens between
>> a variables name and the comma or equal sign. That is:
>>
>> local i: integer = 0
>>
>> In the special mode Lua would ignore everything after 'i' upto the
>> '=' sign. Similarly:
>>
>> function (a: integer, b: integer)
>
> Some silly idea, why not doing it the other way around and use existing
> lua compatible syntax for ravi.
>
>  local i__integer = 0
>  function (a__integer, b__integer)
>
> I know, we all hate hungarian notation, its overly verbose and failed
> in various ways how it is proposed/used in C/C++.

Oh, the verbosity can be cured, by borrowing an idea from
Fortran. (To go with origin-1 indexing, the arithmetic "for", etc.)

Give Ravi a function IMPLICIT (capitals, please! like C preprocessor
directives).

IMPLICIT ("integer", "[^I-N]")

If a name matches the pattern, values assigned to it must be
of the indicated type. Ravi would of course not treat IMPLICIT
as a function but as a compiler directive. It's a function to
allow Lua to do nothing.

To make Ravi programs compile under Lua, one can do this:

lua -e "IMPLICIT=load''" xxx.ravi