Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array accessor custom operator #714

Open
ghost opened this issue Jun 2, 2017 · 6 comments
Open

Array accessor custom operator #714

ghost opened this issue Jun 2, 2017 · 6 comments

Comments

@ghost
Copy link

ghost commented Jun 2, 2017

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
Copy link
Member

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.

@ghost
Copy link
Author

ghost commented Jun 2, 2017

I mean argument that means key/index.

@gabejohnson
Copy link
Member

Can you provide example usage?

@ghost
Copy link
Author

ghost commented Jun 2, 2017

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
Copy link
Member

There's currently no way to use operator or syntax to modify the meaning of delimiters ([],{},()). You'd have to extend the reader.

@ghost
Copy link
Author

ghost commented Jun 2, 2017

I can do array $ptr 0 but this is not very nice syntax. I want like this array |> 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant