Memory Comprehensions

PatrickHaecker
Thu, 15 May 2025 12:46:05 +0000
General Usage

Is there a Memory comprehension in Julia, which I missed so far?

We have Array comprehensions, but when you don’t need the multiple dimensions and resizing properties of an Array and a Memory is enough, it would be nice to construct a Memory directly without going through a (non-public) field access of an Array or an uninitialized Memory and a loop.

[… for …] and (… for …) are already used. {… for …} might be free: But are the cases so common that a dedicated syntax is necessary? On the one hand, Julia’s performance would probably benefit from everyone thinking about whether the functionalities of Array are really needed and make sense. On the other hand, it only gets rid of some inefficiencies, so not too much to gain here.

Would a Memory constructor accepting a generator make sense? This sounds very useful in general and could be a good compromise between code verbosity and syntax complexity.

Or is there any other already existing elegant solution to the problem?

8 posts - 5 participants