Open mratsim opened 2 years ago
To me this doesn't seem as boilerplate at all (actually making it explicit is definitely a good thing!).
It seems to be rather a performance & safety problem (GC).
To me this doesn't seem as boilerplate at all (actually making it explicit is definitely a good thing!).
It seems to be rather a performance & safety problem (GC).
I don't think this is really an issue. It's essentially a "bug" that one cannot just pass a regular seq (I put that into quotation marks, as I don't fully understand where the problems come from). Hiding the required transformation from the user seems nice. Especially, because it is a fully mechanical transformation.
However, there is a practical issue implementing this as far as I can tell:
parallelFor
and friends currently are untyped
macros. That means we have no way to tell, whether something actually is a seq
. So:
typed
macros, but I'm rather certain we don't want to go down that pathparallelFor upper in 0 ..< height:
captures: {width, @distance, @dataset}
# ...
which seems reasonable, given that I don't see why someone would hand some identifier that is supposed to be turned into a sequence in the context of captures
.
either one turns them into typed macros, but I'm rather certain we don't want to go down that path
We don't want to go that path but we can always have the untyped macro quote do
the typed macro like in Arraymancer https://github.com/mratsim/Arraymancer/blob/20e0dc3/src/arraymancer/tensor/accessors_macros_read.nim#L56
The @ would be nice also to indicate transformation of a var T
into ptr T
as well though.
having to
cast[ptr UncheckedArray[T]]
any capturedseq[T]
before use is a lot of boilerplate and quite annoying.Example from Discord: