>>I tried looking into it but I never got around to finding an actual use for it
The only time i've ever seen it used is by people moding the WoW UI.
Mostly familiarity. Plus, it is a very powerful and clean language.
I never said it wasn't powerful or clean, but Lua is those things too.
I don't know of one. There is probably one, but since the standard doesn't specify much in the way of a standard library for accessing an OS outside of a web browser, it'd be of limited usefulness.
Well, crud. Is there an implementation suitable for embedding in applications in general (not just web browsers)? If so, it would be pretty easy to make a standalone implementation with a basic library using that -- that's how the Lua interpreter is designed.
microsoft has wscript.exe and cscript.exe which are standalone jscript (lol) interpreters - they're somewhat oriented towards automated maintenance, as they don't have any builtin messagebox or console output functions, but they do have builtin file i/o functions.
as for embedding JS, i looked around and the only implementation i would trust is mozilla's SpiderMonkey, which is a bit verbose but there seem to be some tools for autogenerating the C<->JS glue code (google jsgen).
I'm only half joking.
Lua apparently has support for coroutines, which is pretty cool.
Coroutines are a generalization of subroutines, allowing one routine to consume as input the output of another routine. Imagine that in C you could write:
for (i = 0; i < 10; i++)
and successive calls to the function would return 0 through 9. That C code doesn't really work, but this is what coroutines let you do. See also:
Another cool language supporting coroutines is Icon, http://www.cs.arizona.edu/icon/. Lua's coroutines were inspired by Icon, I think.
Oh yeah, now I remember reading about those somewhere (probably this board somewhere, lol). Didn't recognise the name, though. Thanks.
This is exactly like Python's yield statement which creates generators which can be iterated or called .next() . An awesome feature BTW, you can do many great things with this, as well as simplify some algorithms by separating them in several functions that take care of a little thing each.
Isn't that a generator? A coroutine is where you have some number of functions A,B... and they can jump inside each other arbitrarily, like this:
|-------+ #back to A
In ye olden days coroutines were used to make lightweight thread-style code, e.g. A is the user (gets input), and B is an AI player. They are still good for making lightweight threads withouot relying on external libraries or loljava.
Incidentally. python wins:
(or, since we aren't passing any arguments, this works too:)
(i for in in range(10))
or, come to think of it, xrange(10) works too, but that doesn't explain anything.
This might be of interest:
By the way, Lua's C API is really fucking annoying. It takes like eight calls to do anything.
when i looked into doing programming on the ipaq PDA,
Also, one student wrote a wrapper around the jscript interpreter library and created an API from his jscript code to the regular windows API. I just tried to locate the forum where I originally read that, but no luck. Sorry. But I remember he showed his source code, and it was easier and smaller than you might think.