Array accessor custom operator
Opened this issue · 6 comments
Deleted user commented
Hello. I also have idea for custom operators with arrays.
operator {@} accessor 19 = (object, index) => {
return #`[object, index]`; // for feed some functions with spreads, for example - Atomics
}
Where symbol @
are divisor between {
and }
.
gabejohnson commented
For your proposed syntax, you'll have to wait for #687 to be resolved.
I'm not sure what accessor
is supposed to designate in your operator
declaration.
Deleted user commented
I mean argument that means key/index.
gabejohnson commented
Can you provide example usage?
Deleted user commented
Really good for SIMD, Typed Array operations, Atomics.
let arrayPtr = typedarray{0}; // getting [typedarray, 0]
// also would be operators with pointers i.e. right pair value
let value = *arrayPtr; // arrayPtr[0][arrayPtr[1]] as getter
*arrayPtr = anotherValue; // arrayPtr[0][arrayPtr[1]] as setter
Atomics.add(...arrayPtr, 1); // using ptr as arguments of Atomics (workers)
gabejohnson commented
There's currently no way to use operator
or syntax
to modify the meaning of delimiters ([]
,{}
,()
). You'd have to extend the reader.
Deleted user commented
I can do array $ptr 0
but this is not very nice syntax. I want like this array |> 0
.