On Mon, 16 Mar 2020, Allin Cottrell wrote:
On Mon, 16 Mar 2020, Sven Schreiber wrote:
> 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.
FWIW, the C translation of Sven's script
<C>
#include<stdio.h>
int printsth() { printf("Hey\n"); return 1; }
int main() { if(printsth()){ } }
</C>
does indeed print "Hey".
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------