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

RFC 1: Arrays #15

Open
kjnilsson opened this issue Jun 19, 2017 · 6 comments
Open

RFC 1: Arrays #15

kjnilsson opened this issue Jun 19, 2017 · 6 comments
Labels

Comments

@kjnilsson
Copy link
Owner

Arrays have no direct equivalent in core erlang. A lot of code that uses arrays can be quite directly translated to using lists instead (fsharp Lists or Seqs). The exception to this is code that mutates the array directly. That said a lot of code may use arrays and it would be good to cover arrays in some shape or form.

The most direct equivalent of erlang's binary() type is the byte array so it would make sense to translate operations on byte arrays to operations on binaries.

Arrays are generic so this leave a lot of types uncovered. Should the non mutable aspects and apis of Array.* that aren't byte arrays simply be translated as erlang lists? Are there any other options?

@kjnilsson kjnilsson added the rfc label Jun 19, 2017
@kjnilsson kjnilsson mentioned this issue Jun 20, 2017
4 tasks
@rascala
Copy link
Contributor

rascala commented Jun 22, 2017

Could it be done as a NIF?
Store an array of pointers to blobs with some methods to manage it?

How much work would it be?

@kjnilsson
Copy link
Owner Author

Manual memory management just doesn't play nicely with the erlang vm typically.

@tsloughter
Copy link

Does it have to be a data structure available in core and not the stdlib? There is the array module, http://erlang.org/doc/man/array.html, which while not being an array like F#'s may give better performance when implementing than a list.

@kjnilsson
Copy link
Owner Author

@tsloughter yes I am leaning towards using the array module for any non-binary types with a fez specific Array.setElement function that returns the array. The problem is that fsharp arrays are mutable and there is no realistic means of supporting functions ( like Array.set) that return unit. The gnarly bit of translating one language into another. :)

@tsloughter
Copy link

Ah yea, set on mutable needs to return unit :(. I'd be curious to a NIF like @rascala suggests, using resources to reference the array. But maybe garbage collection issues with that...

@kjnilsson
Copy link
Owner Author

kjnilsson commented Dec 27, 2017 via email

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

No branches or pull requests

3 participants