May 06, 2010 Re: Fixed-size arrays on the heap | ||||
---|---|---|---|---|
| ||||
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 Re: Fixed-size arrays on the heap | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | 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?
|
Copyright © 1999-2021 by the D Language Foundation