Random numbers

oneill@cs.sfu.ca oneill@cs.sfu.ca
Thu, 14 Dec 1995 14:18:50 -0800 (PST)


Richard Lobb asks:
> Can you not provide facilities in functional languages that let me
> use non-ref transp functions if I really want to, on the understanding
> that by doing so I will significantly reduce the range of optimisations
> that the compiler can perform? [I assume it's possible for the compiler
> to propagate the non ref transp property, and disable optimisations
> that are not legitimate in the abence of referential transparency.]

Within a single module, it might be reasonable to expect the compiler
to keep track of referential transparency violations and so know what
optimizations it can perform, but when one goes across modules things
become more difficult. With Clean's type system as it stands, the compiler
can't know from the interface of a module whether or not its functions
abide by or don't abide by referential transparency.

If one was going to do this `properly', one would, I expect, need to
extend the type system to support referential transparency information,
in rather a similar way to the way Clean currently supports Unique typing
information. (There may of course be pitfalls in trying to do this.)

If you want hidden state, one way of doing it without asking Clean's
designers to spoil the important properties of the language or extend
its type system would be to use a monad. Haskell's designers think monads
so wonderful that they used them instead of Unique types to support IO,
state, etc.

    Melissa.