Just for your fun and horror

Manuel M. T. Chakravarty chak@cse.unsw.edu.au
Sun, 18 Feb 2001 19:54:57 +1100


Ashley Yakeley <ashley@semantic.org> wrote,

> At 2001-02-17 19:50, Manuel M. T. Chakravarty wrote:
> 
> >It is
> >
> >  bar = 42
> >
> >for which C has no corresponding phrase.
> 
> Hmm...
> 
> #define bar 42

No - this doesn't work as 

  #define bar (printf ("Evil side effect"), 42)

is perfectly legal.  So, we have an implicit IO monad here,
too.  What is interesting, however, is that C does not
require `return' in all contexts itself.  Or in other words,
C's comma notation has an implicit `return' in the last
expression.

> ...although I would always do
> 
> const int bar = 42

That's a good one, however.  It in effect rules out side
effects by C's definition of constant expressions.

So, I guess, I have to extend my example to

  bar x = x + 42

Cheers,
Manuel