|
|
||
|
Am 14.01.2014 13:55 schröbte steve donovan:
On Tue, Jan 14, 2014 at 2:41 PM, <colinz@gmx.com> wrote:By the way, is it possible to define some aliases for operators or other syntactic elements? As in the case of .. for concatenation, would it be possible for a programmer to 'rename' it (without changing the source, of course)?Lua is flexible in that way. Operations on strings are 'metamethods' and they can be overrided: Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Riosmt = debug.getmetatable("") smt.__add = function(x,y) return x..y end = "one" + "two"onetwo
This is actually a *very* bad example of when to use the `__add` metamethod, especially to a newbie:
> = "1" .. "2"
12
> = "1" + "2"
3
So please don't do that!
My advice would be: stick to Lua *or* go all the way and write a
BASIC-to-Lua source converter. This way you don't need to write new
documentation, books, tutorials, stackoverflow answers, etc. You can
reuse existing source code (and people can reuse the modules you or your
users will write). And you don't confuse programmers who are already
familiar with Lua or BASIC.
The most prominent example of a source-to-source converter for Lua is
probably Moonscript[1], but there is also Objective Lua[2] which puts
Smalltalk's OO syntax on top of Lua.
As for 'all in one' I do think that the Love2D distribution works like that... steve d.
Philipp [1]: http://moonscript.org/ [2]: http://olua.sourceforge.net/