what is a usage pattern for "static" in an interface?
    Jonathan M Davis 
    jmdavisProg at gmx.com
       
    Sat Feb  4 13:59:09 PST 2012
    
    
  
On Saturday, February 04, 2012 10:45:05 Zach wrote:
> On Saturday, 4 February 2012 at 05:01:10 UTC, Marco Leise wrote:
> > Am 04.02.2012, 02:54 Uhr, schrieb Martin Nowak
> > 
> > <dawg at dawgfoto.de>:
> >> If override were mandatory in implementation classes we could
> >> easily allow implementations
> >> in interfaces.
> > 
> > Do you have a good example? Mine are currently all solvable
> > with final methods in interfaces, like
> > 
> > 	interface ... {
> > 	
> > 		...
> > 		@property size_t length();
> > 		@property final bool empty() { return length == 0; }
> > 	
> > 	}
> 
> There exists std::list implementations in C++ where length is an
> O(n) operation, but empty could still be O(1).
That's why it's good practice to check whether something is empty rather than 
that its length == 0. Containers can optimize empty when they can't 
necessarily do the same with length. Often it doesn't matter, but in general, 
checking for empty is better because of that.
- Jonathan M Davis
    
    
More information about the Digitalmars-d
mailing list