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

Add bigarray literals? #7786

Closed
vicuna opened this Issue Apr 26, 2018 · 5 comments

Comments

Projects
None yet
2 participants
@vicuna
Copy link
Collaborator

vicuna commented Apr 26, 2018

Original bug ID: 7786
Reporter: @nojb
Assigned to: @nojb
Status: closed (set by @nojb on 2018-05-25T05:46:09Z)
Resolution: won't fix
Priority: normal
Severity: feature
Category: standard library
Monitored by: @nojb @hcarty

Bug description

Now that Bigarray is part of the stdlib, I am wondering if we should introduce bigarray literals.

As delimiter the most logical syntax would be {| 1; 2; 3 |}, but that is already taken, so we need an alternative.

Since the bigarray type cannot be deduced from the OCaml type of its elements (e.g. the above bigarray could be of type int8_signed_int or int16_unsigned_int or ...), we also need an optional syntax to specify a concrete bigarray type.

There is also the issue of the empty bigarray: for it, we must always specify the concrete bigarray type since we cannot give it a fully general type ('a, 'b, 'c) Bigarray.Genarray.t.

Opinions?

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Apr 26, 2018

Comment author: @hcarty

A first pass at this could use extension point syntax, along the lines of:

[%bigarray int8_unsigned c_layout {1; 2; 3}]

[%bigarray char c_layout "I'm a bigstring"]

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Apr 29, 2018

Comment author: nholland94

A syntax like what you describe is already available as a ppx package.

https://github.com/akabe/ppx_bigarray

This is really a question of whether or not a new type of literal should be added to the language.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Apr 30, 2018

Comment author: @hcarty

Indeed - my comment was only meant to suggest that a final sugared syntax may not be necessary right away since there are internal changes to go along with this.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented May 21, 2018

Comment author: @xavierleroy

My gut feeling is that this will be a complicated piece of syntax with relatively few uses. I'd rather leave this for a PPX.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented May 25, 2018

Comment author: @nojb

Agreed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.