Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
March 27, 2020 Blog post about multidimensional arrays in D | ||||
---|---|---|---|---|
| ||||
I decided to write a small blog post about multidimensional arrays in D on what I learnt so far. It should serve as a brief introduction to Mir slices and how to do basic manipulations with them. It started with a small file with snippets for personal use but then kind of escalated into an idea of a blog post. However, given the limited about of time I spent in Mir docs and their conciseness, it would be great if anyone had a second look and tell me what is wrong or missing because I have a feeling a lot of things might. It would be a great opportunity for me to learn and also improve it or rewrite some parts. All is here: https://github.com/tastyminerals/tasty-blog/blob/master/_posts/2020-03-22-multidimensional_arrays_in_d.md |
March 27, 2020 Re: Blog post about multidimensional arrays in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to p.shkadzko | On Friday, 27 March 2020 at 10:57:10 UTC, p.shkadzko wrote: > I decided to write a small blog post about multidimensional arrays in D on what I learnt so far. It should serve as a brief introduction to Mir slices and how to do basic manipulations with them. It started with a small file with snippets for personal use but then kind of escalated into an idea of a blog post. > > However, given the limited about of time I spent in Mir docs and their conciseness, it would be great if anyone had a second look and tell me what is wrong or missing because I have a feeling a lot of things might. It would be a great opportunity for me to learn and also improve it or rewrite some parts. > > All is here: https://github.com/tastyminerals/tasty-blog/blob/master/_posts/2020-03-22-multidimensional_arrays_in_d.md I don't really know mir myself, but for the start of the content: > Both array types represent a structure with a length and ptr (a pointer to the first element) properties A static array doesn't really fall under this imo, because it doesn't have any length field at runtime and is literally just the elements repeated N times. > Dynamic arrays are also called slices in D meh, all dynamic arrays are also slices, but not all slices are dynamic arrays. You can take a slice from a static array or from a pointer and once you try to append to it or resize it, it will duplicate the data using the GC and create a new dynamic array. This is true every time you take a slice of any array or memory and then try to resize it. If the slice was originally from a dynamic array (checked using runtime magic) and you use assumeSafeAppend, it will actually try to resize the existing array in-place. |
March 27, 2020 Re: Blog post about multidimensional arrays in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to p.shkadzko | On Friday, 27 March 2020 at 10:57:10 UTC, p.shkadzko wrote:
> I decided to write a small blog post about multidimensional arrays in D on what I learnt so far. It should serve as a brief introduction to Mir slices and how to do basic manipulations with them. It started with a small file with snippets for personal use but then kind of escalated into an idea of a blog post.
>
> However, given the limited about of time I spent in Mir docs and their conciseness, it would be great if anyone had a second look and tell me what is wrong or missing because I have a feeling a lot of things might. It would be a great opportunity for me to learn and also improve it or rewrite some parts.
>
> All is here: https://github.com/tastyminerals/tasty-blog/blob/master/_posts/2020-03-22-multidimensional_arrays_in_d.md
Thanks for doing this.
A small typo on this line
a.byDim1;
I think there would be a lot of value in doing another blogpost to cover some more advanced topics. For instance, mir supports three different SliceKinds and the documentation explaining the difference has never been very clear. I don't really feel like I've ever had a clear understanding of the low-level differences between them. The pack/ipack/unpack functions are also pretty hard to understand from the documentation.
|
March 27, 2020 Re: Blog post about multidimensional arrays in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to WebFreak001 | On Friday, 27 March 2020 at 11:19:06 UTC, WebFreak001 wrote:
> On Friday, 27 March 2020 at 10:57:10 UTC, p.shkadzko wrote:
>> [...]
>
> I don't really know mir myself, but for the start of the content:
>
> [...]
Ok, looks like I need to reread the slices topic. It always confused me especially when it comes to function parameters but I just swallowed it and continued on. Thank you.
|
March 27, 2020 Re: Blog post about multidimensional arrays in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to jmh530 | On Friday, 27 March 2020 at 13:10:00 UTC, jmh530 wrote:
> On Friday, 27 March 2020 at 10:57:10 UTC, p.shkadzko wrote:
>> I decided to write a small blog post about multidimensional arrays in D on what I learnt so far. It should serve as a brief introduction to Mir slices and how to do basic manipulations with them. It started with a small file with snippets for personal use but then kind of escalated into an idea of a blog post.
>>
>> However, given the limited about of time I spent in Mir docs and their conciseness, it would be great if anyone had a second look and tell me what is wrong or missing because I have a feeling a lot of things might. It would be a great opportunity for me to learn and also improve it or rewrite some parts.
>>
>> All is here: https://github.com/tastyminerals/tasty-blog/blob/master/_posts/2020-03-22-multidimensional_arrays_in_d.md
>
> Thanks for doing this.
>
> A small typo on this line
> a.byDim1;
>
> I think there would be a lot of value in doing another blogpost to cover some more advanced topics. For instance, mir supports three different SliceKinds and the documentation explaining the difference has never been very clear. I don't really feel like I've ever had a clear understanding of the low-level differences between them. The pack/ipack/unpack functions are also pretty hard to understand from the documentation.
I agree. I was planning to do several follow-ups after this first brief overview. For example, looks like just one "byDim" requires a separate post.
The goal was just to show ppl who know nothing or a little about D and Mir that Mir exists and is usable. Because what I am lacking is not the API docs but introductory examples how to do mundane tasks like creating matrices and reshaping. Treat the first post as such and if you have suggestions on what is redundant or good to have I shall update it accordingly.
|
March 30, 2020 Re: Blog post about multidimensional arrays in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to p.shkadzko | On Friday, 27 March 2020 at 14:18:13 UTC, p.shkadzko wrote: > I agree. I was planning to do several follow-ups after this first brief overview. For example, looks like just one "byDim" requires a separate post. > > The goal was just to show ppl who know nothing or a little about D and Mir that Mir exists and is usable. Because what I am lacking is not the API docs but introductory examples how to do mundane tasks like creating matrices and reshaping. Treat the first post as such and if you have suggestions on what is redundant or good to have I shall update it accordingly. I am excited about your blog. Exactly what i have been waiting for. If you plan to do more blog posts, please announce it in the "Announce" group and also on reddit (like Ron, e.g. https://forum.dlang.org/thread/gmqqkfzejicevkbaihqt@forum.dlang.org). It really helps to "catch" it. Also, since you put so much work into it, you should put it somewhere (a link) on wiki.dlang.org (https://forum.dlang.org/post/orlwvfedaixnwiekqutx@forum.dlang.org) |
Copyright © 1999-2021 by the D Language Foundation