View mode: basic / threaded / horizontal-split · Log in · Help
July 06, 2007
const const(char)[]
Isn't const const(char)[] equivalent to invariant(char[]) ?
July 06, 2007
Re: const const(char)[]
Funog wrote:
> Isn't const const(char)[] equivalent to invariant(char[]) ?

It doesn't seem to matter whether the brackets are inside or outside the 
parens.  Only the char part is made const or invariant.  I did some 
testing, and couldn't find any difference.  Someone please correct me if 
I'm wrong.

If you're talking about the difference between const and invariant: 
const means that the contents of the array can't be changed through that 
reference.  invariant means that no other reference can change the 
contents either.

This article explains it well:

http://www.digitalmars.com/d/const.html
Top | Discussion index | About this forum | D home