lua-users home
lua-l archive

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

>  - using my add-in class machinery is very error prone because
>    the syntax is all based on tables and functions.

This is an instance of the more general problem that Lua's syntax is not
extensible (at least, not "natively"). By and large, the arguments against
extending syntax on the grounds of lack of usability, language fragmentation
&c. are bogus if you agree that the semantic extension mechanisms are valid.
OTOH, there would be serious concerns about performance and the usability of
such mechanisms, which would have to be addressed, e.g. making sure you
didn't get a compiler that looped or bombed out.

However, these aren't insoluble problems.

>  - combination of add-in class machinery and weak typing makes
>    my Lua code hard to understand and makes errors hard to
>    report about and thus hard to track down.

This is something that ought to be possible to address more with tag methods
(possibly ones that don't exist yet). For example, by having a tag method
for assignment (at the moment there's just setglobal and settable, and no
way of catching assignments to locals), you could have Euphoria-like typing
( you can check that the value being assigned is of
the relevant type, and raise an error if not.

To make this really convenient, a nicer syntax for declarations would be
good, so you can say "[local] [<type>] <variable>", rather than having to
call settag. Also, you'd need to be able to tag any value, not just tables
and userdata (e.g. to do dates and times conveniently).

> I would always start in Python over Lua because I love the clean syntax

How's it cleaner? The use of indenting rather than keywords or punctuation?
Lua's pretty clean...

It does seem from this that stronger typing mechanisms would be a good thing
in Lua, and I'd certainly like to see such things. In particular, perhaps
it's time to think in terms of another level up: rather than implementing
everything in the core, one could, using the existing and perhaps new
meta-mechanisms, implement a typed version of Lua, thus keeping both the
purists who want Lua to stay stable and light happy, as well as those who
want a programming language suitable for bigger projects.

Standard ML may be a good model here: it consists of two essentially
orthogonal languages: the expression language and the module language. Of
course the whole of ML is strongly statically typed, but in Lua perhaps we
could think in terms of an expression language and a type language, where
the latter includes both types and modules (which can be seen as the same
thing at different levels of granularity).

-- | Si hoc legere scis nimium eruditionis habes. (Anon)