| Anonymous | Login | Signup for a new account | 2013-05-24 18:03 CEST | ![]() |
| Main | My View | View Issues | Change Log | Roadmap |
| View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||||||
| ID | Project | Category | View Status | Date Submitted | Last Update | ||||||
| 0005488 | OCaml | OCaml general | public | 2012-01-20 11:48 | 2012-07-10 11:41 | ||||||
| Reporter | lefessan | ||||||||||
| Assigned To | |||||||||||
| Priority | normal | Severity | feature | Reproducibility | always | ||||||
| Status | acknowledged | Resolution | open | ||||||||
| Platform | OS | OS Version | |||||||||
| Product Version | 3.13.0+dev | ||||||||||
| Target Version | Fixed in Version | ||||||||||
| Summary | 0005488: labeled argument in module | ||||||||||
| 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.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. | ||||||||||
| Tags | No tags attached. | ||||||||||
| Attached Files | |||||||||||
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 |
| Copyright © 2000 - 2011 MantisBT Group |