Implicitly converting a newly allocated array to immutable

2014-01-05 Thread Meta
The following doesn`t work: immutable(string[]) strArr = new string[](10); But I feel that it probably should work. I know we have assumeUnique, but I remember awhile ago that some work was done toward making the result of unique expressions (like those using new) implicitly convertible to im

Re: Implicitly converting a newly allocated array to immutable

2014-01-05 Thread Ali Çehreli
On 01/05/2014 05:19 PM, Meta wrote:> The following doesn`t work: > > immutable(string[]) strArr = new string[](10); A pure function is a workaround. The return value of a pure function is implicitly convertible to immutable: pure string[] foo() { return new string[](10); } void main() {

Re: Implicitly converting a newly allocated array to immutable

2014-01-06 Thread Meta
On Monday, 6 January 2014 at 04:10:04 UTC, Ali Çehreli wrote: On 01/05/2014 05:19 PM, Meta wrote:> The following doesn`t work: > > immutable(string[]) strArr = new string[](10); A pure function is a workaround. The return value of a pure function is implicitly convertible to immutable: pure s

Re: Implicitly converting a newly allocated array to immutable

2014-01-06 Thread H. S. Teoh
On Tue, Jan 07, 2014 at 12:01:33AM +, Meta wrote: [...] > Also, is there any hack that I can use to build an AA at compile time? > I have a module level variable that's a string[][string] and I'd like > to initialize it without resorting to static this. Unfortunately, this is currently impossi