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

Syntax improvement for easier binding of record fields #4648

Closed
vicuna opened this issue Nov 17, 2008 · 4 comments
Closed

Syntax improvement for easier binding of record fields #4648

vicuna opened this issue Nov 17, 2008 · 4 comments

Comments

@vicuna
Copy link

vicuna commented Nov 17, 2008

Original bug ID: 4648
Reporter: @mmottl
Status: closed (set by @xavierleroy on 2011-06-04T07:32:17Z)
Resolution: fixed
Priority: normal
Severity: feature
Version: 3.11.0+beta
Fixed in version: 3.12.0
Category: ~DO NOT USE (was: OCaml general)
Monitored by: BenediktGrundmann @glondu "Julien Signoles" hirokawa @yakobowski @mmottl

Bug description

It seems to be one of the more frequent annoyances concerning OCaml syntax that record fields can only be bound/matched explicitly, e.g. in the following way:

let { Foo. some_long_name = some_long_name; b = b } = my_rec in ...

Unless I'm seriously mistaken, it should be very easy to support the following:

let { Foo. some_long_name; b } = my_rec in ...

Especially in cases where there are many record fields and long names this would substantially reduce the effort of extracting/matching records.

This feature wouldn't require any new keywords, wouldn't break existing code, looks very intuitive (AFAIK, SML supports something of that sort), and should be straightforward to implement.

Could you please consider this for inclusion in a future OCaml-release?

@vicuna
Copy link
Author

vicuna commented Nov 21, 2008

Comment author: @oandrieu

FYI, I did a camlp4 syntax extension doing exactly this a couple years ago: http://oandrieu.nerim.net/ocaml/#pa_records
(/!\ it's not a 3.10-camlp4 extension)

It's useful in record expression too (when building a record):

let b = ... in
let some_long_name = ... in
{ some_long_name ; b }

@vicuna
Copy link
Author

vicuna commented Nov 21, 2008

Comment author: @mmottl

Right, record construction should, of course, be treated in the same uniform way, too.

@vicuna
Copy link
Author

vicuna commented Jun 2, 2011

Comment author: @Chris00

Shouldn't this be closed? The requested feature is indeed available in 3.12.

@vicuna
Copy link
Author

vicuna commented Jun 4, 2011

Comment author: @xavierleroy

Christophe is right: this wish was granted in 3.12.0. Closing the PR.

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

No branches or pull requests

1 participant