Re: Ways to initialize static arrays

2010-08-28 Thread Stanislav Blinov
Done: http://d.puremagic.com/issues/show_bug.cgi?id=4745

Re: Ways to initialize static arrays

2010-08-26 Thread Stanislav Blinov
Philippe Sigaud wrote: I have an impression that syntax error is in order. Putting in second array and attempting similar initialization without commas leads to one. I've only tried it with Windows 2.048, though I think the front end would eat this on Linux too. Is this valid,

Re: Ways to initialize static arrays

2010-08-26 Thread Philippe Sigaud
On Thu, Aug 26, 2010 at 23:49, Stanislav Blinov wrote: > struct S(T,size_t N) > { >T[N] arr; >int foo;// type doesn't seem to matter here, >// taking int for clarity > >static immutable S C1 = { initializeWith!(T,N)(0) 5 }; >// No

Re: Ways to initialize static arrays

2010-08-26 Thread Stanislav Blinov
Philippe Sigaud wrote: That beats hell out of my clumsy templates :) Your templates are not clumsy, it's typically the way some other PL would process lists/arrays. I used to write a lot of these. But 6 months ago, CTFE got seven-leagues boots and right now it's much easier on the eye to us

Re: Ways to initialize static arrays

2010-08-26 Thread Philippe Sigaud
On Thu, Aug 26, 2010 at 14:11, Stanislav Blinov wrote: > Sorry, I pressed the wrong button so the message was sent to your email. > Reciting: > > > Does that work for you? >> >> Yes! Beautiful, thanks! That beats hell out of my clumsy templates :) > Your templates are not clumsy, it's typicall

Re: Ways to initialize static arrays

2010-08-26 Thread Stanislav Blinov
Sorry, I pressed the wrong button so the message was sent to your email. Reciting: 26.08.2010 1:53, Philippe Sigaud wrote: I came up with the templates in my initial post. They seem to work, but I doubt those are legal solutions. . If they work, then they are legal :) How i

Re: Ways to initialize static arrays

2010-08-25 Thread Philippe Sigaud
2010/8/23 Stanislav Blinov > I have a struct template (let's call it S) that wraps an array of N > elements. N is set at compile time via template parameter. S uses static > array as storage (T[N]). I need a set of constants of type S which I'd like > to be evaluatable at compile time. I can crea

Re: Ways to initialize static arrays

2010-08-23 Thread Stanislav Blinov
23.08.2010 16:31, bearophile wrote: Stanislav Blinov: I was wondering if anyone has suggestions on performing arbitrary initialization of static arrays, size of which is arbitrary at compile time. Please explain your purposes a bit better. I have a struct template (let's call it S) that wrap

Re: Ways to initialize static arrays

2010-08-23 Thread bearophile
Stanislav Blinov: > I was wondering if anyone has suggestions on performing arbitrary > initialization of static arrays, size of which is arbitrary at compile time. Please explain your purposes a bit better. Bye, bearophile

Ways to initialize static arrays

2010-08-23 Thread Stanislav Blinov
Hello, I was wondering if anyone has suggestions on performing arbitrary initialization of static arrays, size of which is arbitrary at compile time. Consider this: template StaticArray(T,int N,T v) if (N > 0) { static if (N == 1) { enum T[N] StaticArray = cast(T[N])[v];