Pure functions in D

bearophile bearophileHUGS at lycos.com
Wed Oct 8 16:08:08 PDT 2008


renoX:
> Sorry, but this is still above my level of understanding, and I've been 
> programming for quite a long time (and have been curious of many things 
> in programming)..

Around the net there are many tutorials on them, this is very simple:
http://www.reddit.com/r/programming/comments/64th1/monads_in_python_in_production_code_you_can_and/c02u9mb

To understand them I think you can:
- I think you have to "unlearn" some of the things you know;
- read explanations about them
- to install Haskell and start learning it, with time you will learn.


> In general yes, in this case no: AFAIK, monads are only useful for 
> "pure" functional language which D isn't and won't ever be.

If you say you don't undestand monads, how can you tell they can't be useful for the future D?
As far as we today know, monads allow you to use pure functions in the most effective way. For example using monads is the best known way to solve the logging and the exception problems of pure fuctions. So I think they can be useful for the future D too.


> IMHO, functional programming has some good stuff which are easy to use 
> and understand that D should steal such as "pure functions" but monads 
> aren't such thing: they're very hard to understand, so their correct 
> usage isn't obvious and in an impure language I fail to see their interest..

They aren't so hard to understand. In C++ there are several concepts that are as much or more difficult to understand.

Bye,
bearophile



More information about the Digitalmars-d mailing list