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
labeled argument in module #5488
Comments
Comment author: @alainfrisch 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 }). |
Comment author: @garrigue 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. So I vote not to do this: you just have to type a few more characters... |
Comment author: @lefessan I understand Alain's concern, but this is a problem with record label qualification, that should not have been done like that. "A.{ x 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). |
Comment author: @mshinwell Can we come to a final decision on this? |
Comment author: @garrigue 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. |
Original bug ID: 5488
Reporter: @lefessan
Assigned to: @garrigue
Status: resolved (set by @garrigue on 2017-03-16T00:39:23Z)
Resolution: won't fix
Priority: normal
Severity: feature
Version: 3.13.0+dev
Category: language features
Tags: patch
Monitored by: @gasche @hcarty
Bug description
Suppose 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.compare 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.
File attachments
The text was updated successfully, but these errors were encountered: