www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Re: Fixed-size arrays on the heap

reply bearophile <bearophileHUGS lycos.com> writes:
Lars T. Kyllingstad:
 In particular, note Kasumi Hanazuki's post and Andrei's response to it.

Thank you, it seems Andrei agrees with me. But I think here thinks have to be kept tidy, otherwise it's easy to make a mess. The syntax offers various interesting possibilities for a future International Obfuscated D Code Contest: import std.stdio: writeln; struct Arr(int N) { int[N] data; alias data this; } void main() { auto p = new Arr!(10); *p = 10; writeln(p.data); // Output: 10 10 10 10 10 10 10 10 10 10 } This is not good :-( Bye, bearophile
May 06 2010
parent Pelle <pelle.mansson gmail.com> writes:
On 05/06/2010 01:10 PM, bearophile wrote:
 Lars T. Kyllingstad:
 In particular, note Kasumi Hanazuki's post and Andrei's response to it.

Thank you, it seems Andrei agrees with me. But I think here thinks have to be kept tidy, otherwise it's easy to make a mess. The syntax offers various interesting possibilities for a future International Obfuscated D Code Contest: import std.stdio: writeln; struct Arr(int N) { int[N] data; alias data this; } void main() { auto p = new Arr!(10); *p = 10; writeln(p.data); // Output: 10 10 10 10 10 10 10 10 10 10 } This is not good :-( Bye, bearophile

Which is why they decided that the [] will always be needed for array operations. Right?
May 06 2010