Lightfoot8 wrote...
Sorry for getting you riled up and sorry if you dissagree. But I am not talking about compilers, I am talking about only one compiler and that is the compiler that shipped with NWN. That is how the nwn compiler works. Agreed it has been a long time since I have gone through the machine code for the compiler. I can guarantee that that I am not mixing up run time with compile time. The example given above to Whiz was how the compiler would try to compile the script. For what it is worth the nwn compiler compiles line for line like the example I gave to whiz. and yes I know it makes more then one pass.
I am not riled up, darn it
'>
My last statement came out not exactly as I meant it, sorry. Was not trying to sound that critical.
I agree that the compiler generates its code more or less line by line. I say more or less because it
does get muddy when it has to first evaluate arguments before putting them on the stack and those could
be on seperate lines. But that's after the syntax check. It probably does include the type checking.
My points were simply that the first example "while(GetIsObjectValid(target = GetNearestObject(oSource, i++)))"
does not rely on an implementation accident of the code generator. It has to first pass syntactic muster. And
to do that is must be in the grammar of the languange that an assignment operation returns a value. The
fact that it is easy to implement in the generated code because the needed value is left on top of the stack
and all it needs to do is not remove it, is a bonus.
And second WhiZard's example, (x=y) = 0; also does not pass the syntax checking. It is simply not a valid
assignment statement because (x=y) is an expression not a variable and won't parse correctly. So in this case I believe it will fail to compile _before_ it starts the code generation.
This very dated page mentions the actual grammar, although the three issues he mentions seem to
have all been fixed...
http://www2.gamma.uk...?questionID=275
But enough of this flogging a stubborn deer on poor Rolo's dime
'>
Cheers,
Meaglyn