[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Static typing in Lua
- From: Gavin Wraith <gavin@...>
- Date: Thu, 27 Jul 2006 07:56:12 +0100
<firstname.lastname@example.org> you wrote:
> I'm trying to figure if it would be possible to add static (compile
> time) typing to Lua easily, either by adding a library or by modifying
> the language parser itself. Has anyone already looked into it and
> found something interesting ? Is the Lua core designed to allow such
> modification ? An alternative would be to add a kind of preprocessor
> to Lua. I read somewhere that there is a Lua parser written in Lua.
> Would it be capable of doing such preprocessing ?
> Static typing enforce some level of code correcteness and that's the
> aspect of it that I'm looking for.
I have been thinking about this a little. The function
the = function (s,x)
if assert(type(x) == s) then return x end
which is useful for superficial typechecking, suggests the use
of identity functions with side effects which create type
I think nil has to have every type.
As to what constitutes a type perhaps one should go through
all the code in the VM looking for branching decisions, and
make an abstract definition of "a type relevant to a given
VM operation" as something that resolves branches for that
op. Or am I being silly? This is a notion analyzed from the
point of view of the cpu rather than the user, so to speak,
and so may not be quite what you mean.
Gavin Wraith (email@example.com)
Home page: http://www.wra1th.plus.com/