[phobos] Pureness of enforce()
    Lars Tandle Kyllingstad 
    lars at kyllingen.net
       
    Tue Nov  9 03:21:38 PST 2010
    
    
  
enforce(x) is basically a substitute for
  if (x) throw new Exception;
which doesn't violate the purity rules.  It is not possible to annotate
enforce() with 'pure', however, because it takes a lazy parameter, which
is just shorthand for a (possibly impure) delegate.
enforce() is used virtually everywhere in Phobos, and this means that a
lot of functions that could otherwise be marked as pure, currently
can't.
One example is std.conv.to(), which should definitely be pure.  (In
fact, I tried marking it as such, which is what got me thinking about
this in the first place.)
What to do?
-Lars
    
    
More information about the phobos
mailing list