runtime static arrays

Namespace rswhite4 at googlemail.com
Tue Nov 20 15:30:16 PST 2012


> It's pretty trivial to create a struct which uses malloc and 
> free to create a
> dynamic array of the exact size that you want with 
> deterministic destruction,
> and you can easily overload the indexing and slicing operators 
> - though
> clearly, as if with static arrays, you'd have to be careful 
> with slices being
> passed around, since they're not owned by the GC. And I'm not 
> sure what would
> happen if you were foolish enough to try and append to them.
>
> Personally though, I wish that the length of static arrays 
> could be set at
> runtime and don't really understand why you can't (aside from 
> the fact that
> you can't in standard C - gcc will let you though).
>
> - Jonathan M Davis

Yeah, but it's inconvenient to use a struct instead of a built in 
solution. ;)


More information about the Digitalmars-d-learn mailing list