On Mon, 16 Mar 2020, Sven Schreiber wrote:
Am 16.03.2020 um 21:24 schrieb Artur Tarassow:
> Hi,
>
> this is a point I don't understand and frequently stumble over.
>
> Function main() calls checker(). When checker() is called first, it
> correctly prints the message "Some error message" and correctly returns 1.
>
> When checker() is called within the conditional-statement, <if
> checker(1)>, it also returns correctly 1 which triggers printing the
> message "Check returned some other error". However, printing the
> checker's message "Some error message" 'fails' or is not done.
Why is
> this the case?
Hi Artur, I think your example could be much shorter:
<hansl>
function scalar printsth(void)
print "hey"
return 1
end function
if printsth() # does not spit out "hey"
endif
</hansl>
Frankly, don't know if it's by design, but could be I guess.
The idea is that if printsth() is called in its own right we want to
see anything it might print, but if it's called under "if" then all
we're interested in is its return value. From that point of view,
while the "if-block" above is entered OK (which can be verified by
putting a print statement within it) it's empty and so nothing is
printed.
Admittedly one could make a case for showing printed output, if any,
from a function call regardless of whether it serves as a boolean
switch. So far as I know that's not an issue that has been raised to
date, but it's open for discussion.
Allin