Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005488OCamlOCaml generalpublic2012-01-20 11:482013-11-29 13:01
Reporterlefessan 
Assigned To 
PrioritynormalSeverityfeatureReproducibilityalways
StatusacknowledgedResolutionopen 
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
end

Further, suppose you have:

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

Then you could write:

List.sort ints ~compare:Int.compare

Or, you could write:

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

List.sort ints ~Int.compare

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.
Tagspatch
Attached Filespatch file icon qualified_labeled_arguments.patch [^] (436 bytes) 2012-01-20 11:48 [Show Content]

- Relationships

-  Notes
(0006762)
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 }).
(0006764)
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...
(0006765)
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).

- 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


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker