Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005488OCamllanguage featurespublic2012-01-20 11:482017-03-16 01:39
Assigned Togarrigue 
StatusresolvedResolutionwon't fix 
PlatformOSOS Version
Product Version3.13.0+dev 
Target VersionFixed in Version 
Summary0005488: labeled argument in module
DescriptionSuppose you have a function:

module List : sig
  val sort : 'a t -> compare:('a -> 'a -> int) -> 'a t

Further, suppose you have:

module Int : sig
  val compare : t -> t -> int

Then you could write:

List.sort ints

Or, you could write:

Int.( ints ~compare)
It would be nicer to instead just write:

List.sort ints

To be precise, when passing a labeled argument without using :, module prefixes would be allowed. Only the name of the value (excluding the module path) would be required to match the label name in the function signature.

I provide a patch for this in attachment.
Attached Filespatch file icon qualified_labeled_arguments.patch [^] (436 bytes) 2012-01-20 11:48 [Show Content]

- Relationships

-  Notes
frisch (developer)
2012-01-20 19:39

This is nice. I've a little concern: if this is accepted, users might (with reason) ask the same for record fields with punning. But the syntax { A.x } already has a different meaning (namely { A.x = x }, and not { x = A.x }).
garrigue (manager)
2012-01-21 04:45

Originally the intent of the ~ident notation is to make easier using labeled arguments in recursive functions, or in function calls where an argument has the same meaning.
I don't think that extending this to values inside modules is very reasonable.
Moreover, as Alain points out, this would not be coherent with the punning for records.

So I vote not to do this: you just have to type a few more characters...
lefessan (developer)
2012-01-22 22:44

I understand Alain's concern, but this is a problem with record label qualification, that should not have been done like that. "A.{ x
; y; z }" would have been a much better syntax (and much easier to understand, you qualify the record, not the content).

It is a pity that such a mistake would now prevent the introduction of an unambiguous syntax (with labels, there is no risk of ambiguity, about what is qualified by the module).
shinwell (developer)
2016-12-07 18:52

Can we come to a final decision on this?
garrigue (manager)
2017-03-16 01:39

While I can understand why you would wish to write more compact code, you already describe how to this with a local open. From the point of view of readability, I think this is clearer not to introduce yet another rule.

- Issue History
Date Modified Username Field Change
2012-01-20 11:48 lefessan New Issue
2012-01-20 11:48 lefessan File Added: qualified_labeled_arguments.patch
2012-01-20 19:39 frisch Note Added: 0006762
2012-01-21 04:45 garrigue Note Added: 0006764
2012-01-22 22:44 lefessan Note Added: 0006765
2012-01-23 00:27 gasche Status new => acknowledged
2012-07-10 11:41 doligez Severity minor => feature
2013-11-29 13:01 doligez Tag Attached: patch
2016-12-07 18:52 shinwell Note Added: 0016800
2017-02-23 16:36 doligez Category OCaml general => -OCaml general
2017-03-03 15:36 doligez Description Updated View Revisions
2017-03-03 15:38 doligez Category -OCaml general => language features
2017-03-16 01:39 garrigue Note Added: 0017685
2017-03-16 01:39 garrigue Status acknowledged => resolved
2017-03-16 01:39 garrigue Resolution open => won't fix
2017-03-16 01:39 garrigue Assigned To => garrigue

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker