Functions and procedures

I am considering segregating methods into functions and procedures. A function is side effect free. Like a mathematical function it transforms set of input values into an output value. On the other hand, a procedure may have statements with side effects, like assignment statements or output.

Questions:

Functions could provide all kinds of benefits—expression statements? would be limited to function calls only.

return for each x in container:
    sqrt(x) < 10;

In fact, this could be the way to distinguish between expression and non-expression versions of a statement. An expression statement contains only function calls, whereas a non-expression statement can contain procedure calls but is more restricted in usage.

It's not necessary to limit expression statements to function calls alone, however. Question: Are there any useful uses of side effects in expression statements that this constraint would prevent?

Edit this page | 6 years, 8 months old