Poll: Would you like to try const-by-default or not?

Sean Kelly sean at f4.ca
Tue Jun 12 09:58:05 PDT 2007


Jarrett Billingsley wrote:
> This is not a discussion thread.  I think we've discussed enough.  :)
> 
> Basically there are these possible const implementations (there are others, 
> but for the sake of simplicitly, I'll keep this poll to 2):
> 
> 1) C++ style const, where you mark anything that should be const as such.
> 
> 2) Parameters are const-by-default, and must be marked mutable otherwise. 
> Locals, fields etc. are still mutable by default.

I'd like to at least try option 2.  It sounds appealing in theory, but 
it's hard to say whether I'd actually like it without actually using it. 
  My only stipulation is there there must be some way to do this:

     void fn( char[] a ) { a[0] = 'a'; }

     fn( ("xxx".dup)[0 .. 1] );

ie. pass a temporary array (slice, etc) as a parameter whose contents 
are modifiable.


Sean



More information about the Digitalmars-d mailing list