On 15 Dec 2003 at 23:35, CBFalconer wrote:
[...]
This focus on ParamCount is a red herring. That was just a trivial test program (as Frank always emphasises) that shows the problem. ParamCount is not the problem here. Rather, it is the warning about a ";" following a "then" that was being highlighted.
My point, which I probably did not make clear, is that the only use for a null statement after a then is to discard something in the conditional part. Having discarded the need for this by using clearer methods, such a null THEN clause is clearly a programmatic error and a warning can only be useful.
I am not sure how something is an error, if it is something that I intend to do, does not cause my program to behave in a manner that I do not expect or want, and does not violate the language.
IMHO having to create any number of junk variables just for the purpose of discarding things is undesirable. I don't see how it is "clearer" either. It ought to be pretty clear to anyone that the value is being deliberately discarded when a "then" is followed by a semi-colon. Finally, your solution still generates a warning (or "hint") in other Pascal implementations. For example, this program:
program foo; var i : integer; homedir : string [255]; begin {....} chdir (homedir); i := ioresult; end.
generates this under Delphi: "Value assigned to 'i' never used" and this under FPC: "Local variable "i" is assigned but never used"
Seems that you are damned if you do and you are damned if you don't ...
In this example, all I want is to try to go somewhere before doing something else, and I don't need to know (or care) whether it happens successfully or not, because it is of no real consequence either way. I of course want to clear IOResult, and I don't want any complaints. This scenario is of course contrived.
I guess "If ioresult = 0 then begin end;" is the way to go in order to satisfy all compilers ...
Best regards, The Chief -------- Prof. Abimbola A. Olowofoyeku (The African Chief) web: http://www.bigfoot.com/~african_chief/