Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If the parameters to a pure function are marked immutable, then you cannot change data referenced by those arguments. It's functionally pure.

Ironically, sometimes people complain that the purity checks are too stringent :-)

One thing interesting about pure functions in D is the purity restrictions can be relaxed by using a `debug` prefix:

    pure int test(int i) {
      printf("%d\n", i); // error, printf isn't pure
      debug printf("%d\n", i); // ok
      return i;
    }
This makes it very, very handy to debug your functional code.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: