I disagree for two reasons:

1.  enforce() generates so much code that it's likely that very few compilers would inline it, and then also inline the function calling it.

2.  Even if enforce() does get inlined and the checks become cheaper, IMHO ranges need to be a lightweight enough abstraction that there's zero overhead in release mode, kind of like arrays (which are themselves ranges).  A major goal of ranges is that they are supposed to be an extremely lightweight abstraction that can be used even in the most performance-critical code.

I generally agree with the view that input to a public API should be checked come Hell or high water, but I think exceptions can be made for things that are intended to be very efficient, lightweight abstractions.  Builtin arrays are one of these.  Ranges should be another.

On 8/21/2010 7:19 PM, Brad Roberts wrote:
On 8/21/2010 2:29 PM, Andrei Alexandrescu wrote:
  
On 08/21/2010 01:52 PM, David Simcha wrote:
    
It seems like the consensus here is that, for range primitives, assert()
is the way to go. I'd like to commit the changes in time for the next
release, but I'd like to have Andrei's nod first b/c he's been quiet
throughout this discussion and he's the main designer of std.range and
std.algorithm.
      
Thanks - I feel like a mobster who's being given respect :o). I thought of this
a lot, and talked with Walter as well. Will get back with an opinion today.

Andrei
    
The part I dislike the most is that this decision is being heavily influenced by
a dmd quality of implementation issue.  Primarily, the inlinability of enforce
vs assert.
_______________________________________________
phobos mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/phobos

  

_______________________________________________
phobos mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/phobos

Reply via email to