pure functions

sarn via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Sep 12 22:02:22 PDT 2016


On Tuesday, 13 September 2016 at 03:33:04 UTC, Ivy Encarnacion 
wrote:
> Can pure functions throw exceptions on its arguments?

You can throw exceptions for whatever reasons from a function 
marked pure:

void foo() pure
{
	throw new Exception("nope");
}

void main()
{
	foo();
}

> Also, how can it perform impure operations?

Well, the point of pure is to restrict you from doing that.  Is 
there something specific you're trying to do?


More information about the Digitalmars-d-learn mailing list