Questions about compiling (MARK???)!

BlitzMax Forums/BlitzMax Programming/Questions about compiling (MARK???)!

DH(Posted 2005) [#1]
Ok, trying to write a decent scripting system with blitzmax (so far so good), however when the arguments are evaluated in a function call (any type of function be it user defined or language specific), are the arguments evaluated from right to left? Can that be counted on?

I know one shouldn't rely on that sort of thing, however I would like to have user refferenced functions between the script and the actual program, and to make things simple I want to do something like:

select functype
case 1 myfunc(Getint(),GetString(),GetFloat))
end select


Where the GetInt,GetString,GetFloat are merely tie-in functions for the (x86 style) push/pop stack...

Can one assume that this will always getfloat first, then getstring, then getint and THEN pass them all to the function?

Thanks,


Floyd(Posted 2005) [#2]
I wrote a comment in the Blitz3D thread before I saw this. It's more likely to get noticed here so I will just copy it.

In my opinion the right approach would be for the docs to clearly state that the order is not specified. Then the compiler may change the order and still be playing by the rules. This might be needed for optimization, which is why the C standard left the order unspecified. This applies to the operands needed by an operator as well as to arguments needed by a function.

The usual trick is to do the more complicated evaluation first. For example, suppose that b() needs more registers than a() and we want to evaluate the expression

a() + b()

as efficiently as possible. Perhaps this can be done entirely in registers only by evaluating b() before a().
Thus a() + b() needs a different left-to-right order than b() + a().


dmoc(Posted 2005) [#3]
Is the post about order of evals or stack parameters?