function predefinition

Posted By: Damocles

function predefinition - 03/26/06 18:08

Actually, there is the requirement to define
function dummies, if a function is called in the
script, if the function itself is defined "lower" in the script.
Otherwise the function is not found. (sometimes the compiler finds it,
even if it is defined "lower", very strange)

How about that the compiler first checks the script for
all actions and function and variables, that are placed,
and then starts the real compilation,
this leaves the need for predefinition out,
And would speed up the implementation of new function a bit,

or is there some restriction to this mehtod?
Posted By: FRAJO

Re: function predefinition - 03/26/06 18:11

function dummy_func;


function dummy_func()
{
....
}
Posted By: Damocles

Re: function predefinition - 03/26/06 18:12

Yes I know how to predefine functions,
but I dont see the deeper sense in this requirement.

Java for example does not require this.
Posted By: LarryLaffer

Re: function predefinition - 03/26/06 19:24

Quote:

Otherwise the function is not found. (sometimes the compiler finds it,
even if it is defined "lower", very strange)




it will only find it if the function has none or one parameter. more than one parameters require the function to be predefined

I doubt they're gonna make any such improvements to c-script. Hopefully, lite_c will be more flexible in that matter
Posted By: jcl

Re: function predefinition - 03/27/06 09:51

The doubt is justified - the hope is not.
Posted By: Matt_Aufderheide

Re: function predefinition - 03/27/06 13:25

LOL!

Funny

Pretty much all structured programming languages and compilers need to have the functions, variables, classes, etc all defined before they are called. This is the basis of the structured approach, dating way back. I dont think Conitec is going to try to change this.
Posted By: Damocles

Re: function predefinition - 03/28/06 13:43

Java does not..
I guess the reason for the predefinition is just to have
it more simple to program the compiler.
Posted By: Doug

Re: function predefinition - 03/28/06 19:37

Quote:

I guess the reason for the predefinition is just to have
it more simple to program the compiler.




Yes, but some people also find it useful for avoiding bugs (however, with today's compilers it probably isn't needed).

The main reason we'll probably stick with it is because it's done this way in C so it should be done this way in Lite-C.
© 2024 lite-C Forums