Why the code
if some_bool_var then
begin
output_string some_file "some string"; (* <--- error here *)
end
generates “applied to too many arguments” error. But if I change it to
if some_bool_var then output_string some_file "some string";
it compiles fine.
Why is it so?
Thank you.
I’m pretty skeptical that what you’ve presented doesn’t compile. I copied it into the top level and sure enough I’m not getting an error at all.
The problem is most likely not what you’ve typed but what is after what you’ve typed. I’m guessing you’ve got more lines of code for this particular function, thus
endshould have a semi-colon after it denoting the end of that command. Think ofbegin ... endas an alternative to( ... ), and...;as an alternative tolet () = ... in. Thus, usingbegin ... endis not a replacement for the use of a semicolon.Also, the semi-colon that ends your
output_stringcall betweenbeginandendis unnecessary since that block does not continue with more commands.