A fundamental problem with AGS Script.

Started by Calin Leafshade, Wed 23/07/2014 09:45:10

Previous topic - Next topic

Calin Leafshade

I was pondering the scripting language last night and I've noticed something of a problem that should be addressed.

AGS is type safe and we're getting rid of pointer notation. Without a base object class (and type coercion) we can't have any kind of generic classes, like a stack for instance.

In C you might push pointers to a general stack.
In C# you'd use a generic or a general bass class.

We can't do either of those because there's no object class and no generics/templates.

So I propose we introduce both. I think all user structs should inherit from a base "object" class and generics should be introduced.

Both of these things seem *fairly* easy to me (although I know very little about compilation).

Requiring all classes extend object is presumably just something thats implied by the compiler.
Generics are just a type substitution thats known at compiler time.. it could almost be a find/replace.

Code example for reference:

Code: ags

class Stack<T> {
    import T Pop();
    import void Push(T item);
}


Code: ags

class object {
    import String ToString();
}

SMF spam blocked by CleanTalk