Category:Fexl: Difference between revisions

m
whitespace
No edit summary
m (whitespace)
Line 12:
For example, here is the C routine which implements the classic '''S''' combinator (fusion), where (S x y z) = (x z) (y z):
 
<lang C>value fexl_S(value f)
value fexl_S(value f)
{
if (!f->L->L || !f->L->L->L) return f;
return A( A(f->L->L->R, f->R), A(f->L->R, f->R) );
}</lang>
</lang>
 
Fexl functions may have side effects -- after all, they've gotta happen '''somewhere'''. For example here's the implementation of the char_put function, called as (char_put ch next), which prints the single character ch to stdout and then continues with next:
 
<lang C>value fexl_char_put(value f)
value fexl_char_put(value f)
{
if (!f->L->L) return f;
Line 31 ⟶ 28:
putchar(get_long(x));
return f->R;
}</lang>
</lang>
 
Fexl is very free-wheeling about side effects, because of course they must happen '''somewhere'''. But you the Fexl programmer can easily isolate and confine side effects as diligently as you like, factoring them out systematically, applying monadic techniques, or whatever.
Anonymous user