[Suggestion] Forward declaration of functions

You can talk about ManiaScript for ManiaPlanet here

Moderator: English Moderator

Post Reply
User avatar
m4rcel
Posts: 650
Joined: 15 Jun 2010, 11:12
Contact:

[Suggestion] Forward declaration of functions

Post 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.
ImageImage
Image
User avatar
Gugli
Nadeo
Nadeo
Posts: 536
Joined: 14 Jun 2010, 17:35
Location: Mon PC est à Paris, mais mon coeur rode dans les forêts de Lozère

Re: [Suggestion] Forward declaration of functions

Post 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.
--
(>~_~)> ═╦═ ╔╦╗ <(~_~<)
User avatar
m4rcel
Posts: 650
Joined: 15 Jun 2010, 11:12
Contact:

Re: [Suggestion] Forward declaration of functions

Post 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 ^^
ImageImage
Image
User avatar
Gugli
Nadeo
Nadeo
Posts: 536
Joined: 14 Jun 2010, 17:35
Location: Mon PC est à Paris, mais mon coeur rode dans les forêts de Lozère

Re: [Suggestion] Forward declaration of functions

Post 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 ^_^
--
(>~_~)> ═╦═ ╔╦╗ <(~_~<)
Post Reply

Return to “ManiaScript”

Who is online

Users browsing this forum: No registered users and 2 guests