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

Comments

Projects
None yet
1 participant
@vicuna
Copy link
Collaborator

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

This comment has been minimized.

Copy link
Collaborator Author

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

This comment has been minimized.

Copy link
Collaborator Author

commented Nov 21, 2008

Comment author: @mmottl

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

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

commented Jun 2, 2011

Comment author: @Chris00

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

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

commented Jun 4, 2011

Comment author: @xavierleroy

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

@vicuna vicuna closed this Jun 4, 2011

@vicuna vicuna added the feature-wish label Mar 19, 2019

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.