shared arrray problem

ag0aep6g via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Nov 19 17:52:21 PST 2016


On 11/20/2016 01:33 AM, Charles Hixson via Digitalmars-d-learn wrote:
> Yes.  I was hoping someone would pop up with some syntax making the
> array, but not its contents, const or immutable, which I couldn't figure
> out how to do, and which is what I really hoped would be the answer, but
> it appears that this isn't part of the syntax.

Yup, head const is not part of the language. You'd have to find a 
library solution or write something yourself.

> I really *can't* allow the length to be
> changed,

Your emphasis suggests that user could break things for your code. They 
can't. Any changes to the length will only affect the slice on the 
user's end. They can only fool themselves. That may be bad enough to 
warrant a more restricted return type, but for your code it's safe to 
return a plain dynamic array.


More information about the Digitalmars-d-learn mailing list