Const sucks

Bruno Medeiros brunodomedeiros+spam at com.gmail
Mon Sep 10 18:17:58 PDT 2007


Walter Bright wrote:
> Bruno Medeiros wrote:
>> As Regan asked before, and how would that work for classes? This is a 
>> most fundamental issue that has not been mentioned. Without a way to 
>> declare tail const/invariant, this design, no matter how simpler or 
>> more understandable, is fundamentally *broken*.
> 
> What, exactly, is the use case that needs a solution?

Before hand, let me just say that by broken, I didn't mean subvertable, 
but rather that using const/invariant with classes would be impractical 
and unmanageable.

Simple example: Let's say you have a class Foo that is comparable. How 
do you sort an array of const(Foo)'s ?

   const(Foo)[] sort(const(Foo)[] arr) {
      ... ?
The sorting algorithm doesn't matter, what matters is: how would one 
swap two elements in the array?


-- 
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D



More information about the Digitalmars-d mailing list