Fixing const arrays
    Jonathan M Davis 
    jmdavisProg at gmx.com
       
    Sat Dec 10 15:15:49 PST 2011
    
    
  
On Sunday, December 11, 2011 08:01:57 kenji hara wrote:
> 2011/12/11 bearophile <bearophileHUGS at lycos.com>:
> > kenji hara:
> >> It breaks IFTI rule,
> > 
> > What do you mean?
> 
> I mean following code comment will not become true.
> 
> void func(T)(T prm){}
> void main(){
>    X arg;
>    func(arg);  // T is deduced to typeof(arg)
> }
Why does that matter? What does it affect?
As far as functions go, it means that
immutable str = "hello";
func(str);
would instantiate to
func!string
instead of
func!(immutable string)
which will no affect on the internals of the function except for the fact that 
it's no possible to alter the function parameter. The contents of the array 
are immutable regardless.
In what situation would it matter that it's now func!string instead of func!
(immutable string)?
- Jonathan M Davis
    
    
More information about the Digitalmars-d
mailing list