leledumbo wrote:
Joost van der Sluis wrote:
And there's no way the compiler can detect this.
I don't think so. The compiler understand that a procedure doesn't return a
value while a function does (i.e. trying to return a value from a procedure
causes compile error). I haven't checked how compiler formats each
function/procedure in the PPU but I think there should be an information
whether it's a function or procedure. So, I think it's possible to detect if
a function call is assigned to a variable or not.
Yes. Turn Extended Syntax off {$X-}, then a function result must be
assigned to a variable. At least it used to be that way.
I was used to it, and in the case I really needed to ignore the result
(and rather just wanted the side-effects of the function) I wrote things
like:
|if (IOResult <> 0) then {null};
Well, then ... I started with classes:
Now, constructors seem to actually return something (not surprisingly),
so "inherited Create" did not compile anymore (and I remember that any
attempt to assign this "result" to a dummy variable even failed). So, at
that time I turned the extended syntax stuff back on.
So, in theory your problem is already solved in the compiler (even TP6
already had it), but alas, in practice it's not really usable.
Vinzent.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal