Page 1 of 1

[Suggestion] Forward declaration of functions

Posted: 04 Jan 2012, 21:12
by m4rcel
The bigger a ManiaScript become, the more functions you add to it. And sooner or later you will stand before the problem: How to order the functions? Currently, where ever you call a function, this function must be defined somewhere before.

My suggestion is to introduce some kind of forward declarations of functions (afaik called prototyping in C/C++), so that the concrete order become less important. Let's have a small example showing what I mean:

Code: Select all

Integer DoSomething(Integer Param); // Forward declaration, "This function comes later"

Integer DoSomethingElse(Integer Param) {
    return DoSomethind(Param) + 42;
}

// Finally define the function
Integer DoSomething(Integer Param) {
    return 1337;
}
This becomes important if you have two functions, which call each other to do some stuff -- Currently you have to go another way, as you cannot define each function before the other.

Re: [Suggestion] Forward declaration of functions

Posted: 11 Jan 2012, 16:10
by Gugli
I think it would be easier if the declaration of functions was not depending on the order. One should be able to put them in any order, as soon as every called function is here, it should compile.

It's already in my ToDo-list. No deadline though.

Re: [Suggestion] Forward declaration of functions

Posted: 12 Jan 2012, 11:22
by m4rcel
I assumed that the function (or at least its signature) must be known to the compiler when it is called, to be able to e.g. check the parameters (like it is in C/C++). Of course having no required order of the functions would be even better ^^

Re: [Suggestion] Forward declaration of functions

Posted: 17 Jan 2012, 12:00
by Gugli
Since the scritpt language is "home made" we can do whatever we like to ^_^. But it takes time, so we have to prioritize ^_^