I would like to add scripting support to an applications and with plenty scripting languages available I am a bit overwhelmed.
At first I thought about Python but I guess Python is a little too big for my taste and the application (although I like it very much, it gets a lot of things right in my opinion while the syntax is clean and simple especially if you are not doing heavy OOP).
I am also very fond of Lisps. I like scheme and it is the perfect extension language – at least in some ways, but I would like to stay syntactically more conservative.
I remember having heard a lot of positive things about Lua and indeed Lua seems a good possibility. Unfortunately there is this one thing that really “turns me off”: Its the local
keyword for local binding. This is really ugly to my taste and I frankly do not quite grok why languages are still designed this way and in essence knowing about local
. This is also a major drawback of JavaScript in my opinion and I feel like it all boils down to bad language design. My major concern is, that a user might just override a function from just within her/his function just by omitting local
.
But then Lua gets a lot of things right, size, speed, and it is surprisingly scheme-esque. Yet I am really afraid that it is not suitable for non-programmers who have no sense of scope.
- Any alternatives on the horizon?
-
Might hacking the Luacore to make local the default be an option?
Lua sources appear to be quite decent and modular, so this would be an interesting project 😉
6
local
is mandatory attribute of full lexical scoping:
local x = 0
function f(inc)
x = x + inc -- if you auto-localize it, this is broken
end
On the other hand, we probably could remove local
from the language, but add complementing outer
(bound
, upvalue
, you name it):
x, y = 0, 0
function f(inc)
outer x
x = x + inc -- uses outer slot: "0 + inc"
y = y + inc -- creates local (and raises "nil + number" error)
end
If you do not have either (including regular globals), your scoping is just useless.
Lua parser is written well, although I don’t think it will be trivial fix.
4
I’d suggest TCL, its designed to be an embedded scripting language that can define DSLs for non-programmers.
The key thing with TCL, scheme or any solution here though is designing a DSL that the user can understand, with a good enough DSL the user should rarely need general programming constructs (which could be harder to comprehend)
WRT your comment TCL doesn’t really have a grammar so I wonder if you are misunderstanding something about it? Or rather its grammar is about as complex as schemes.