Fake global associative array literals

2011-10-28 Thread bearophile
What do you think about a rewrite rule that changes code like: int[int] aa = [1:2, 3:4]; void main() {} Into: int[int] aa; static this() { aa = [1:2, 3:4]; } void main() {} Bye, bearophile

Re: Fake global associative array literals

2011-10-28 Thread Nick Sabalausky
"bearophile" wrote in message news:j8eflp$q3o$1...@digitalmars.com... > What do you think about a rewrite rule that changes code like: > > int[int] aa = [1:2, 3:4]; > void main() {} > > > Into: > > int[int] aa; > static this() { >aa = [1:2, 3:4]; > } > void main() {} > You generally need to

Re: Fake global associative array literals

2011-10-28 Thread bearophile
Nick Sabalausky: > So as nice as it would be to use AA initializers at the module-level, this > carries a hidden danger which could be a royal PITA to debug (especially for > D newbies), so I don't think it's a good thing to do. I see. Thank you for your answer. Bye, bearophile

Re: Fake global associative array literals

2011-10-29 Thread bearophile
Nick Sabalausky: > You generally need to be very careful about adding module/static ctors, > because they can easily lead to the dreaded circular ctor runtime error. So > as nice as it would be to use AA initializers at the module-level, this > carries a hidden danger which could be a royal PIT

Re: Fake global associative array literals

2011-10-29 Thread Jonathan M Davis
On Saturday, October 29, 2011 05:20:35 bearophile wrote: > Nick Sabalausky: > > You generally need to be very careful about adding module/static ctors, > > because they can easily lead to the dreaded circular ctor runtime error. > > So as nice as it would be to use AA initializers at the module-lev

Re: Fake global associative array literals

2011-11-09 Thread sergk
On Fri, Oct 28, 2011 at 5:53 PM, bearophile wrote: > What do you think about a rewrite rule that changes code like: > > int[int] aa = [1:2, 3:4]; > void main() {} > > > Into: > > int[int] aa; > static this() { >    aa = [1:2, 3:4]; > } > void main() {} Its not quite same case, but still could be