Note that the dual feature does not exist for variant constructors, because it is easy to define only on the constructor at the toplevel of the pattern, and nested patterns get us in muddy waters. On Tue, Aug 18, 2015 at 2:52 PM, David Allsopp wrote: > Goswin von Brederlow wrote: > > On Fri, Aug 14, 2015 at 01:28:50PM +0200, Drup wrote: > > > > > > >You can't qualifylocal values or values of the surrounding module so > > > >that is a no go. > > > > > > > >I also often use local open to access records, as in: > > > > > > > >let r = M.({ x = 1; y; z = depth; }) in > > > > > > You can avoid the local open altogether and write it like that: > > > > > > let r = {M. x = 1; y; z = depth } in > > > > > > It's even shorter. > > > > That only works because newer ocaml disambiguises (is that a word?) > record > > So it's implicitly using M.y = y and M.z = depth. > > labels when it determines the record type from the first label, right? > > Only since you ask: "disambiguates" :o) That said, it's quite common to > see words like "disambiguises" being invented by Americans! > > But this isn't related to the disambiguation features of OCaml 4.01+. > Those allow you to write things like: > > type t = {x : int} > type u = {x : int; y : string} > > let foo = {x = 1} > let bar = {x = 42; y = ""} > > This is actually a much older notation added in OCaml 3.08. Prior to that, > if you hadn't opened a module you had to qualify each label: > > {M.x = 1; M.y = y; M.z = depth} > > but this was "silly", since it's not possible to use non-equivalent module > paths for labels, so OCaml 3.08 changed it so that you only needed to put > the module path on one label (and it doesn't have to be the first one, it's > just a bit weird to put it in the middle!). > > OCaml 3.12 added, amongst other record-related goodies, the shorthand {y} > to mean {y = y}. So while you can use local open as you're using it, you've > been able to do it as a totally unambiguous language feature for quite some > time. > > > David > > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >