[challenge] Limitation in D's metaprogramming

Michael Stone mstone at xx.xxx
Mon Oct 18 19:05:32 PDT 2010


bearophile Wrote:

> Jonathan M Davis:
> 
> > You can think of a monad as an extra parameter which is passed to each function 
> > and holds the global state. It isn't a hole in purity at all. For instance, it's 
> > how Haskell manages to have I/O and yet be functionally pure. You don't need the 
> > compiler's help to do monads - it's just easier if you have it.
> 
> Yet, sooner or later the compiler has to help you giving you a hole to let the contents of those I/O monads pass though to/from the outside world, otherwise you will not see any program input/output unless you use something like a post-mortem debugger :-) So I think the Haskell compiler has to manage your I/O monads in a special way anyway. Purity can't be absolute.

The stdin/(stdout/stderr) streams/pipes form a pure system with eager evaluation of the application in my opinion. You can use monads to propagate the state through the application naturally in this way.

The arguments about real world are silly in this context. Even the operating system, the compiler and the processes are all abstactions. The real world operates with resistances, capacitances, voltages etc.


More information about the Digitalmars-d mailing list