The only thing it really uses from CC is the fs and term APIs. But, that's only if you use the Luva.lua file (From
github).
Using the other two files, Lexer.lua and Compiler.lua, should be fine in a standard Lua environment as far as I know.
Also:
Konlab, on 21 March 2016 - 09:41 AM, said:
About custom keywords I meant like adding interfaces, delegates, events etc. Or generics or other things I want through an API
I don't really think interfaces are needed, as, if you were to have this C# example (found
here):
using System;
public interface IGenerate
{
int Generate();
}
// Dependencies
public class KnownNumber : IGenerate
{
public int Generate()
{
return 5;
}
}
public class SecretNumber : IGenerate
{
public int Generate()
{
return new Random().Next(0, 10);
}
}
class Game
{
public Game(IGenerate generator)
{
Console.WriteLine(generator.Generate())
}
}
new Game(new SecretNumber());
new Game(new KnownNumber());
You could just make it become:
local SecretNumber = [Generate: function() { return math.random(0, 10) }]
local KnownNumber = [Generate: function() { return 5 }]
local class Game(generator: table) {
private function init {
guard type(generator.Generate) == "function" else { error("Table must have a Generate function!") }
print(generator.Generate())
}
}
Game(SecretNumber)
Game(KnownNumber)
Events (or Delegates):
local class Event {
private:
subscribers = []
subs = 0
public static:
function add(f: function) {
subs++; subscribers[subs] = f; return subs
}
function rem(n: number) {
if n == subs { subs-- }; subscribers[n] = nil
}
function clr {
for i = 1, subs { subscribers[i] = nil }; subs = 0
}
public static metamethod:
function add = self.add
function sub = self.sub
function call(...) {
for i = 1, subs { subscribers[i](...) }
}
}
I also feel as if Generics aren't really needed either, since type specification is optional in Luva.
Feel free to call me out if my examples or something I said here is wrong or something, since I don't really use interfaces, delegates, etc.
Edited by Detective_Smith, 21 March 2016 - 09:33 PM.