-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Jesse Phillips wrote: > http://stackoverflow.com/questions/1008803/how-to-use-pure-in-d-2-0 > > class TestPure > { > string[] msg; > void addMsg( string s ) > { > msg ~= s; > } > }; > > pure TestPure run2() > { > TestPure t = new TestPure(); > t.addMsg("Test"); > t.addMsg("this."); > return t; > } > > This doesn't work and the answer from CyberShodow is that you could thread > inside the pure function modifying the class value at the same time. Isn't > that still an issue if TestPure was change to an int?
Pure functions are not allowed to alter global state. That's what you doing when you create a new object. http://en.wikipedia.org/wiki/Functional_programming - -- My enormous talent is exceeded only by my outrageous laziness. http://www.ssTk.co.uk -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFKOrzET9LetA9XoXwRAr7yAJ95tUQ5E6blpFHmnRCSaAcYdN1wCgCeLmZi Bg8FdF/yxx3iR4LS5T+NXsE= =0WQ0 -----END PGP SIGNATURE-----
